- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircularPrime.py
More file actions
Latest commit
38 lines (30 loc) · 862 Bytes
/
Copy pathcircularPrime.py
File metadata and controls
38 lines (30 loc) · 862 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
32
33
34
35
36
37
38
defisPrime(n: int) ->bool:
ifn<=1:
returnFalse
elifnin [2, 3, 5, 7]:
returnTrue
elifn%2==0orn%3==0:
returnFalse
else:
r=5
whiler*r<=n:
ifn%r==0:
returnFalse
r+=2
ifn%r==0:
returnFalse
r+=4
returnTrue
defcircularStrings(num: int) ->str:
length=len(str(num))
foriinrange(1, length):
yieldstr(num)[i:]+str(num)[:i]
defhasDivisibleLastDigit(n: int) ->bool:
returnany([din'024568'fordinstr(n)])
defcircularPrime(n: int):
ifn<10:
returnisPrime(n)
ifhasDivisibleLastDigit(n):
returnFalse
returnall(isPrime(i) foriincircularStrings(n))
print(circularPrime(12))