The Sieve of Eratosthenes is a method for finding all primes up to (and possibly including) a given natural . This method works well when is relatively small, allowing us to determine whether any natural number less than or equal to is prime or composite.
We now explain how the Sieve of Eratosthenes can be used to find all prime numbers up to a given natural number. Recall that is a multiple of means that divides , see Definition 4.1.
The next integer on the list that is not marked out is 3, and it is prime. Mark out all multiples of 3 that are bigger than 3 because they are composite. (Note that some of these, such as 6, will already be marked out).
The next integer on the list that is not marked out is 5, and it is prime. Mark out all multiples of 5 that are bigger than 5 because they are composite.
Explore the sieving process in Figure 10.7. Click on a number to have all its multiples marked by changing the field color to red and crossing them out. Numbers that you have clicked appear on green background. When there are no white fields left, the numbers in green fields are all the prime numbers up to 192.
It is most efficient to follow the strategy presented in Strategy 10.1. In particular that means first clicking on , then clicking on the first number that remained white, which is and so on. To illustrate the sieving better multiples are marked with a delay and different shades of red are used for multiples of different numbers.
Figure10.7.Interactive Sieve of Eratosthenes up to . Click on a number to sieve out its multiples. Auto Sieve goes through the complete sieving process. Reset Sieve clears the sieve.