1456 """ import primeutils import math def rotate(s): return s[1:] + s[0] def rotations(n): str_n = str(n) rs = [] for i in xrange(len(str_n)): str_n = rotate(str_n) rs.append(str_n) return rs count = 0 for n in primeutils.primes_below(1000000): prime_rotations = [primeutils.is_prime(int(j)) for j in rotations(n)] if all(prime_rotations): count += 1 print count # print rotate('197') # print rotate(rotate('197')) # print rotations(197)
"""The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million.""" import primeutils print sum(n for n in primeutils.primes_below(2000000))