Why it matters
Linear sieve is elegant O(n) alternative. Understanding shapes optimization.
Advertisement
The architecture
Iterate i from 2 to n.
If not marked: prime.
Mark i * prime for primes <= smallest prime factor of i.
Advertisement
How it works end to end
Linear time.
Yields smallest prime factor.
Multiplicative function computation.