-
Notifications
You must be signed in to change notification settings - Fork 0
/
35.py
44 lines (40 loc) · 862 Bytes
/
35.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
36
37
38
39
40
41
42
43
44
import time
from math import sqrt
t= time.time()
def prime(x):
if x%2==0:
return False
for i in range(3,int(sqrt(x)+1),2):
if x%i==0:
return False
return True
def check(x):
for i in x:
if int(i)%2==0:
return False
return True
def rotate(a):
l = []
b = str(a)
for i in range(len(b)):
temp = b[:-1]
c = b[-1]
c += temp
b = c
l.append(int(b))
return l
def solution():
num = []
for i in range(1000000):
if check(str(i)):
l = rotate(i)
flag = True
for j in l:
if not prime(j):
flag = False
if flag :
num.append(i)
print(num)
print(len(num))
solution()
print(time.time()-t)