Objects/Documentation
roues.py
I use digits to extract mixed-radix digits, unrank to rotate suffixes, and rank to recover the offsets. The faster variants use a Fenwick tree.
Download ↓"""Machines factoradiques — références exactes, Python 3.10+, bibliothèque standard."""
from math import factorial, gcd, isqrt, prod
from functools import lru_cache
from bisect import bisect_right
def primes_up_to(n):
if n < 2: return []
a = bytearray(b'\x01')*(n+1); a[:2] = b'\x00\x00'
for p in range(2,isqrt(n)+1):
if a[p]: a[p*p:n+1:p] = b'\x00'*((n-p*p)//p+1)
return [i for i,v in enumerate(a) if v]
def digits(n,r):
if n<1 or r<0: raise ValueError('n ou rang invalide')