Number theory · Prime numbers

Sieve of Eratosthenes

Enter a number and watch every prime up to it appear, one step at a time.

Your number

Step by step

Step 0

–Current prime p
0Primes found
0Crossed out
0Still unmarked

The sieve

Key

Not yet decided Prime Crossed out by the current prime Crossed out earlier Being examined

The method

  1. List every whole number from 2 to n. The number 1 is left out because it is not prime.
  2. Let p = 2, the first prime.
  3. Cross out the multiples of p, starting at p² and counting up in steps of p.
  4. Move p to the next number that is still unmarked. It is prime, because no smaller prime divides it.
  5. Repeat while p² ≤ n. Once p² is larger than n, stop: every number still unmarked is prime.