Atelier des rouesLab FR
Objects/Documentation

primitives.py

PrimitiveCounter applies the truncated convolution logarithm and Möbius inversion to quotient classes. The tests include the scalar count at one million.

Download ↓
"""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:

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.