project-euler/429_sum_of_squares.py

22 lines
291 B
Python
Raw Normal View History

#!/usr/bin/env python3
from lib import primegen
def fpw(p, n):
pw = 0
pwofp = p
while pwofp <= n:
pw += n // pwofp
pwofp *= p
return pw
N = 10**8
mod = 10**9 + 9
k = 1
for p in primegen(N+1):
k *= pow(p, 2 * fpw(p, N), mod) + 1
k %= mod
print(k)