Skip to content

Instantly share code, notes, and snippets.

@FrankSpierings
Created July 12, 2017 16:06
Show Gist options
  • Save FrankSpierings/d996063d277bd3d3f6183fad052713ca to your computer and use it in GitHub Desktop.
Save FrankSpierings/d996063d277bd3d3f6183fad052713ca to your computer and use it in GitHub Desktop.
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