-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem_35.py
More file actions
31 lines (23 loc) · 777 Bytes
/
Problem_35.py
File metadata and controls
31 lines (23 loc) · 777 Bytes
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
from Problem_27 import Prime
def rotate(l, n):
eqRot = n%(len(l))
return l[-eqRot:] + l[:-eqRot]
def allNumberRotations(num):
digits = len(str(num))
return set([int(rotate(str(num), i)) for i in range(0, digits)])
def main():
p = Prime()
print(p.primesList()[-1])
p.find(max_prime=1000000)
print(p.primesList()[-1])
circularPrimes = set()
for prime in p.primesList():
if prime not in circularPrimes:
allRotations = allNumberRotations(prime)
if all([p.isPrime(n) for n in allRotations]):
for numOfList in allRotations:
circularPrimes.add(numOfList)
print(numOfList)
print(len(list(circularPrimes)))
if __name__=='__main__':
main()