Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
from primesieve import primes
|
||||
from math import isqrt
|
||||
from functools import cache
|
||||
|
||||
p = primes(isqrt(1_000_000_000))
|
||||
|
||||
@cache
|
||||
def phi(x, a):
|
||||
res = 0
|
||||
while True:
|
||||
if not a or not x:
|
||||
return x + res
|
||||
|
||||
a -= 1
|
||||
res -= phi(x//p[a], a) # partial tail recursion
|
||||
|
||||
def legpi(n):
|
||||
if n < 2: return 0
|
||||
|
||||
a = legpi(isqrt(n))
|
||||
return phi(n, a) + a - 1
|
||||
|
||||
for e in range(10):
|
||||
print(f'10^{e}', legpi(10**e))
|
||||
Loading…
Add table
Add a link
Reference in a new issue