-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem035.py
45 lines (33 loc) · 909 Bytes
/
problem035.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
45
def criba_eratostenes(n):
primes = []
multiplos = set()
for i in range(2, n+1):
if i not in multiplos:
primes.append(i)
multiplos.update(range(i*i, n+1, i))
return primes
def is_circular_number(number,primes):
is_circular_prime = False
len_number = len(str(number))
for i in range(1,len_number):
number = str(number)[1:len_number] + str(number)[0]
_number = int(number)
if _number in primes:
is_circular_prime = True
else:
is_circular_prime = False
break
return is_circular_prime
def main(n):
primes = criba_eratostenes(n)
count = 4 # [2,3,5,7]
suma = 0
for prime in primes:
result = is_circular_number(prime,primes)
if result:
#print("primo circular:",prime)
count += 1
suma += prime
print("Numero de primos circulares:",count)
return
main(1000000)