Skip to content

Instantly share code, notes, and snippets.

@lezi
Last active September 26, 2015 00:38
Show Gist options
  • Save lezi/1010676 to your computer and use it in GitHub Desktop.
Save lezi/1010676 to your computer and use it in GitHub Desktop.
detect is a number is prime
#verify is a number is prime
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