Objets/Documentation
primitives.py
Calcul par logarithme de convolution tronqué et inversion de Möbius. L’objet PrimitiveCounter renvoie des comptes par classes du quotient choisi. Le script test_primitives.py fournit notamment le témoin scalaire à un million.
Télécharger ↓"""Exact formal convolution logarithm on integer magnitude x finite unit quotient.
No list of integer primes is used by this oracle. Rational arithmetic only.
"""
from fractions import Fraction
from functools import lru_cache
from bisect import bisect_right
from math import gcd
@lru_cache(None)
def mobius(k):
if k==1:return 1
return -sum(mobius(d) for d in range(1,k) if k%d==0)
def iroot(x,k):
lo=0;hi=1<<( (x.bit_length()+k-1)//k )
while lo<hi: