Smallest prime factor sieve
ID: smallest-prime-factor-sieve
A smallest prime factor sieve stores the least prime divisor for integers up to a bound . Initialize entries unset; scan primes in increasing order and fill their still-unset multiples. A composite first marked by has no smaller prime divisor, so the stored value is correct. For example, repeatedly dividing by its stored factors gives , hence . A table uses entries and accelerates repeated factorizations; the values at zero and one need a separate sentinel convention.
New to topics? Read the docs here!