-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem034.py
More file actions
55 lines (48 loc) · 1.03 KB
/
Copy pathProblem034.py
File metadata and controls
55 lines (48 loc) · 1.03 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def PrimesSet(n):
'''this lists primes below the value n'''
m = [0] * n
j = 3
SetOfPrimes = [2]
while j < n:
if m[j] == 0:
SetOfPrimes += [j]
p = j
while p < n:
m[p] = 1
p += j
j += 2
return SetOfPrimes
def IntShiftr(n):
'''takes int abc and returns bca'''
s = str(n)
sh = str()
for x in s:
sh = s[-1]+s[0:-1]
#print(sh)
return int(sh)
ListOfPrimes = PrimesSet(1000000)
SetOfPrimes = set(ListOfPrimes)
b = set()
le = len(ListOfPrimes)
i = -1
while i < le-1:
i += 1
prime = ListOfPrimes[i]
l = len(str(prime))
c = set()
#print(prime)
if prime not in b:
while l > 0:
prime = IntShiftr(prime)
c.add(prime)
l -= 1
d = set()
for x in c:
if x in SetOfPrimes:
d.add(x)
if len(d) == len(c):
#print(d)
for y in d:
b.add(y)
#print(b)
print(len(b))