Skip to content

Instantly share code, notes, and snippets.

@aivuk
Created July 29, 2014 18:45
Show Gist options
  • Save aivuk/c66e68b0da1c6bebed60 to your computer and use it in GitHub Desktop.
Save aivuk/c66e68b0da1c6bebed60 to your computer and use it in GitHub Desktop.
import re
def is_prime(n):
ns = ''.join(['1' for _ in range(n)])
return not re.match(r'^1?$|^(11+?)\1+$', ns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment