You are on page 1of 1

""" Circular primes Problem 35 The number, 197, is called a circular prime because all rotations of the digits:

197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73 , 79, and 97. How many circular primes are there below one million? """ # # Project Euler: Problem 35 # def isprime(n): if n == 4: return False for i in range(2,int(n**0.5)+1,1): if n % i == 0: return False return True def rotnum(n): nstr = int(str(n)[-1]+ str(n)[:-1]) return nstr print "-> Creating list" plst = [] for i in range(2,1000000,1): if isprime(i): plst.append(i) if i % 10000 == 0: print i/10000. print "-> Creating list.... Done"

You might also like