Skip to content

Instantly share code, notes, and snippets.

@stan
Created August 21, 2010 19:42
Show Gist options
  • Save stan/542760 to your computer and use it in GitHub Desktop.
Save stan/542760 to your computer and use it in GitHub Desktop.
# http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/
def is_prime(n)
("1" * n) !~ /^1?$|^(11+?)\1+$/
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment