from euler.prime import PrimenessChecker pc = PrimenessChecker("primes.txt", maxprime=1000000) circularcount = 0 for i in range(len(pc.primes)): p = pc.primes[i] if p < 10: circularcount += 1 continue allprime = 0 pstr = str(p) for s in range(len(pstr)): pstr = pstr[1:] + pstr[0] anint = int(pstr) if not pc.is_prime(anint): break else: allprime = 1 if i % 10000 == 0: print i if allprime == 1: circularcount += 1 print circularcount
from euler.prime import PrimenessChecker pc = PrimenessChecker('primes.txt', maxprime = 2000000) result = [-1000, -1000, 0] def quadratic(a, b, n): return n**2 + a*n + b for a in range(-999, 1000): for b in range(-999, 1000): n = 0 count = 0 while pc.is_prime(quadratic(a, b, n)): count += 1 n += 1 if count > result[2]: result = [a, b, count] if a % 100 == 0: print a # progress report print result print result[0] * result[1]