28 lines
503 B
Python
28 lines
503 B
Python
#!/usr/bin/env python3
|
|
|
|
def add_divisors(n):
|
|
for k in range(1, (len(sieve) - 1) // n):
|
|
sieve[k*n] *= n * (sieve[k] // sieve[k*n])
|
|
|
|
def primes(n):
|
|
for p in range(3, int(n**0.5), 2):
|
|
if sieve[p] != 1:
|
|
continue
|
|
for i in range(p**2, n, 2*p):
|
|
sieve[i] = 0
|
|
|
|
n = 10**5
|
|
sieve = [1] * n
|
|
|
|
add_divisors(2)
|
|
add_divisors(5)
|
|
primes(n)
|
|
|
|
s = 0
|
|
|
|
for p in range(7, n, 2):
|
|
if sieve[p] == 1 and pow(10, sieve[p-1], 9*p) != 1:
|
|
s += p
|
|
|
|
print(s + 2 + 3 + 5)
|