Overview
The Sieve of Eratosthenes keeps a table of candidate integers and marks multiples of each prime starting at p squared. Unmarked values that remain are prime.
Finds all primes up to a limit by repeatedly crossing out multiples of each discovered prime.
Compact metadata for implementation and discovery.
The Sieve of Eratosthenes keeps a table of candidate integers and marks multiples of each prime starting at p squared. Unmarked values that remain are prime.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n log log n)
Average
O(n log log n)
Worst
O(n log log n)
Space
O(n)
Show crossing out multiples of each discovered prime on a small prime generation example.
For a single large candidate, probabilistic or deterministic primality tests are usually more appropriate than sieving up to that number.
What each reference supports for this entry.
Reference for Sieve of Eratosthenes's arithmetic operations, modular arithmetic, multiplication, division, or number-theoretic implementation details.
Open sourceTextbook support for Sieve of Eratosthenes's algorithm family, complexity framing, and standard implementation concepts.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Numerical Methods · Core
Both address modular system solving, but they make different modeling or performance tradeoffs.
Compare with thisCryptography · Core
Miller-Rabin tests individual large candidates rather than enumerating all primes up to a limit.
Compare with thisSieve of Atkin is a more advanced prime sieve with different arithmetic filters.
Miller-Rabin tests individual large candidates rather than enumerating all primes up to a limit.
Primality testing and modular arithmetic routines often appear together in number-theory code.