from gauss import is_prime from gauss import perms sup = 0 digs = '987654321' while 1: for perm in perms(digs): if is_prime(int(perm)): if int(perm) > sup: sup = int(perm) digs = digs.replace(digs[0], '') if sup: print sup; break
from gauss import primes from gauss import perms tot = 0 lprimes = list(primes(2, 17)) i = 1 for perm in perms('0123456789'): while i < 8: if int("".join(perm[i:i+3])) % lprimes[i-1]: i = 1 break i += 1 if i == 8: tot += int(perm) i = 1 print tot
from gauss import primes from gauss import perms lprimes = list(primes(1000, 10000)) def is_add_seq(x, y, z): return z - y == y - x i = 0 for x in xrange(1, len(lprimes)): a = lprimes[x] lperms = list(perms(str(a))) for y in xrange(x+1, len(lprimes)): b = lprimes[y] if not str(b) in lperms: continue for z in xrange(y+1, len(lprimes)): c = lprimes[z] if not str(c) in lperms: continue if is_add_seq(a, b, c): i += 1 if i == 2: print "%s%s%s" % (a, b, c)
from gauss import perms l = [] permsl = list(perms("123456789")) for perm in permsl: if int(perm[:1]) * int(perm[1:5]) == int(perm[5:]) or \ int(perm[:2]) * int(perm[2:5]) == int(perm[5:]): l.append(int(perm[5:])) print sum(set(l))