Created
July 12, 2017 16:06
-
-
Save FrankSpierings/d996063d277bd3d3f6183fad052713ca to your computer and use it in GitHub Desktop.
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
import string | |
from math import sqrt; from itertools import count, islice | |
def isPrime(n): | |
return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1))) | |
orgname = input('Give me a name:') | |
name = orgname.lower() | |
name = name.replace(' ','') | |
#Check illegal chars | |
ill = False | |
for letter in name: | |
if letter not in string.ascii_lowercase: | |
print('Illegal character: {0}'.format(letter)) | |
break | |
if not ill: | |
strSum = "" | |
for letter in name: | |
strSum += "{0:d}".format(string.ascii_lowercase.index(letter) + 1) | |
print(strSum) | |
isum = int(strSum, 10) | |
print(isPrime(isum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment