// NUMBER THEORY · BEGINNER
Sieve of EratosthenesThe most ancient and elegant way to catch all prime numbers in a range — one simple rule: cross out the multiples.
Prerequisites: Multiplication tables · Prime vs composite
// VISUALIZER
Catch the primes one multiple at a time
Change the limit n and press play. The sieve starts with 2, then 3, then 5 — each time crossing out all multiples of the current prime.
Press PLAY to watch the Sieve of Eratosthenes mark non-prime numbers.
Step
0 / 77
Primes Found
0
Crossed
0
// MINI GAME
Sieve Sweep
Beat the clock and cross out every multiple of the current prime. Miss one or click a non-multiple and your streak resets.
Sieve Sweep
Click all the multiples of the current prime before the timer runs out.
// FLOWCHART
Algorithm flow
Press PLAY to trace the algorithm through the flowchart.
// PSEUDOCODE
Trace the code
Press PLAY to step through the algorithm line by line.
// TUTORIAL QUIZZES
Test your mastery
Three progressive quizzes. Prove you can sieve, understand the complexity, and name the variants.
// PRACTICE & ASSESS
Test your understanding
Now that you've learned the concept, put it into practice. Solve coding problems and take quizzes to reinforce what you've learned.
// REFERENCES
Sources & further reading
- [1]Sieve of EratosthenesEratosthenes of Cyrene (~240 BC)
- [2]Introduction to Algorithms (CLRS)T. H. Cormen et al. — Number-theoretic algorithms
- [3]The Art of Computer Programming, Vol. 2Donald Knuth — Section 4.5.4: factoring into primes
- [4]Prime Numbers and Computer Methods for FactorizationHans Riesel — sieve methods and algorithms
// READY?
Break numbers into their building blocks
Next up: Prime Factorization. Learn how to break any number into its unique product of primes.