euler/python/e133.py

24 lines
445 B
Python
Raw Normal View History

2024-04-26 01:01:38 +02:00
from lib_prime import primes
def r_modulo_closed_form(n, m):
assert n > 0 and m > 0
return ((pow(10, n, 9 * m) - 1) // 9) % m
def euler_132():
n = 10**20
r = 0
for p in primes(100_000):
if r_modulo_closed_form(n, p) == 0:
pass
else:
r += p
return r
if __name__ == "__main__":
solution = euler_132()
print("e132.py: " + str(solution))
assert solution == 453647705