Last active
September 26, 2015 00:38
-
-
Save lezi/1010676 to your computer and use it in GitHub Desktop.
detect is a number is prime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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