Sieve of Eratosthenes

The sieve of Eratosthenes is a method of listing all the primes up to a given number. In the diagram, 2 is prime, and all larger multiples of 2 are composite. 2 is ringed are all proper multiples of 2 - every second number - are crossed out.

sieve of eratistheners

The first number after 2 not crossed out is prime. This number is 3 so ring it and cross out all proper multiples of 3 - every third number.
The first number after 3 not crossed out is prime. This number is 5 so ring it and cross out all proper multiples of 5 - every fifth number.
The first number after 5 not crossed out is prime. This number is 7 so ring it and cross out all proper multiples of 7 - every seventh number.
Continuing in this way, the ringed numbers are all primes.

Add comment

Security code
Refresh