If I could just learn how to read directions correctly the first time, I wouldn’t have to bang my head against the wall when I don’t get the correct answer. Also, it ends up the question they were actually asking was easier than what I thought they were asking.
#evaluate if a number is prime or not
def isprime(n):
for i in range(2, int(n**0.5 + 1)):
if n%i == 0: return 'FALSE'
return 'TRUE'
#take a string of form (1, 2, a, b) and make it into one word or number of form 12ab
def str2num(n):
return ''.join(map(str, n))
import itertools
for r in range(1, 10):
for n in itertools.permutations(range(1, r+1), r):
thisnumber = int(str2num(n))
if (isprime(thisnumber) == 'TRUE'):
print thisnumber, 'is prime'