26 lines
505 B
Python
26 lines
505 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
def primes(n):
|
||
|
sieve = [False] * n
|
||
|
yield 2
|
||
|
for p in range(3, n, 2):
|
||
|
if sieve[p]:
|
||
|
continue
|
||
|
for i in range(p**2, n, 2*p):
|
||
|
sieve[i] = True
|
||
|
yield p
|
||
|
|
||
|
def search(i=0, n=1, sign=1):
|
||
|
r = 0
|
||
|
while squares[i] * n <= N:
|
||
|
m = n * squares[i]
|
||
|
r += sign * (N // m)
|
||
|
r += search(i+1, m, sign * (-1))
|
||
|
i += 1
|
||
|
return r
|
||
|
|
||
|
N = 2**50
|
||
|
squares = [p**2 for p in primes(2**25)] + [N+1]
|
||
|
|
||
|
print(N - search())
|