Created
November 15, 2014 17:19
-
-
Save hunterhector/7f7b1714576abc6f8c3b to your computer and use it in GitHub Desktop.
Regex 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
#!/usr/bin/python | |
import re | |
def regex_prime(n): | |
l = "1" * n | |
return re.match(r"^1?$|^(11+?)\1+$", l) == None | |
while True: | |
n = raw_input("\nEnter a number and test for prime:") | |
try: | |
print(regex_prime(int(n))) | |
except ValueError: | |
print("not an integer\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment