BEGINNER · 10 MIN · FREE LESSON
Sieve of Eratosthenes
Explore sieve of eratosthenes through a visual, step-by-step model.
Loading interactive lesson…
BEGINNER · 10 MIN · FREE LESSON
Explore sieve of eratosthenes through a visual, step-by-step model.
Loading interactive lesson…
Enter an integer from 2 to 128.
Zero and one are not prime; all larger keys are candidates.
Each prime marks its multiples starting at its square; repeated composite marks sum to the prime harmonic series.
Composite marks, seed 42. Plotted sample sizes respect each lesson’s explicit input limits.
Keyboard: Space play/pause · ←/→ step · R restart · 1–5 speed. Reduced motion disables transitions.
Mark every seat number divisible by a smaller prime; the unmarked seats are the ones that no smaller factor can explain.
Cross out multiples. Keep the primes. Edit the validated input or seeded preset to explore a different case.
Predict the next arithmetic decision, cache victim, sample replacement or cluster assignment before revealing it.
The sieve uses O(n) memory and O(n log log n) marking work. Starting at p² avoids redoing smaller multiples solely to rediscover them. The chart names its counted or modeled work rather than pretending animation duration is a benchmark.
The four reference languages show the core operation; numeric bounds and state assumptions match the input help. Exact power examples use arbitrary-precision integers.
Use it to find every prime up to a moderate bound, especially before many primality queries.
A single-number test and a sieve solve different workloads. Zero and one are not prime, and p itself must not be crossed out.
Check the invariant and cost model, then explain one boundary case using the live counters.
MAKE IT STICK
Progress saves on this device and merges with your account after sign-in.
0 / 5000 · Saved on this device; synced when signed in.