-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPE35.py
35 lines (28 loc) · 795 Bytes
/
PE35.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from math import sqrt
def isPrime(numToCheck, listPrimes):
for i in range(0, len(listPrimes)-1):
if numToCheck % listPrimes[i] == 0:
return False
return True #Only true if all the primes are checked.
def isCircular(num, listP):
numList = []
while num not in numList:
numList.append(num)
tempstr = str(num)
tempstr = tempstr[1:] + tempstr[0]
num = int(tempstr)
if not isPrime(num, listP):
return 0
return numList
myList = []
myPrimes = [2]
for i in range(3, 1000000, 2):
if isPrime(i, myPrimes):
myPrimes.append(i)
tempn = isCircular(i, myPrimes)
if tempn != 0:
for i in tempn:
myList.append(i)
print myPrimes
print myList
print len(myList)