2.1: The Sieve of Eratosthenes
A prime is an integer greater than 1 that is only divisible by 1 and itself. The integers 2, 3, 5, 7, 11 are prime integers. Note that any integer greater than 1 that is not prime is said to be a composite number.
The Sieve of Eratosthenes
The Sieve of Eratosthenes is an ancient method of finding prime numbers up to a specified integer. This method was invented by the ancient Greek mathematician Eratosthenes. There are several other methods used to determine whether a number is prime or composite. We first present a lemma that will be needed in the proof of several theorems.
Every integer greater than one has a prime divisor.
We present the proof of this Lemma by contradiction. Suppose that there is an integer greater than one that has no prime divisors. Since the set of integers with elements greater than one with no prime divisors is nonempty, then by the well ordering principle there is a least positive integer \(n\) greater than one that has no prime divisors. Thus \(n\) is composite since \(n\) divides \(n\). Hence \[n=ab \mbox{with} \ \ 1<a<n \mbox{and} \ \ 1<b<n.\] Notice that \(a<n\) and as a result since \(n\) is minimal, \(a\) must have a prime divisor which will also be a divisor of \(n\).
If \(n\) is a composite integer, then n has a prime factor not exceeding \(\sqrt{n}\).
Since \(n\) is composite, then \(n=ab\), where \(a\) and \(b\) are integers with \(1<a\leq b<n\). Suppose now that \(a>\sqrt{n}\), then
\[\sqrt{n}<a \leq b\]
and as a result
\[ab>\sqrt{n}\sqrt{n}=n.\]
Therefore \(a\leq \sqrt{n}\). Also, by Lemma 3, \(a\) must have a prime divisor \(a_1\) which is also a prime divisor of \(n\) and thus this divisor is less than \(a_1 \leq a\leq \sqrt{n}\).
We now present the algorithm of the Sieve of Eratosthenes that is used to determine prime numbers up to a given integer.
The Algorithm of the Sieve of Eratosthenes
- Write a list of numbers from 2 to the largest number \(n\) you want to test. Note that every composite integer less than \(n\) must have a prime factor less than \(\sqrt{n}\). Hence you need to strike off the multiples of the primes that are less than \(\sqrt{n}\)
- Strike off all multiples of 2 greater than 2 from the list . The first remaining number in the list is a prime number.
- Strike off all multiples of this number from the list.
- Repeat the above steps until no more multiples are found of the prime integers that are less than \(\sqrt{n}\)
Exercises
- Use the Sieve of Eratosthenes to find all primes less than 100.
- Use the Sieve of Eratosthenes to find all primes less than 200.
- Show that no integer of the form \(a^3+1\) is a prime except for \(2=1^3+1\).
-
Show that if \(2^n-1\)
is prime, then \(n\) is prime.
Hint: Use the identity \((a^{kl}-1)=(a^{k}-1)(a^{k(l-1)}+a^{k(l-2)}+...+a^k+1)\).
Contributors and Attributions
-
Dr. Wissam Raji, Ph.D., of the American University in Beirut. His work was selected by the Saylor Foundation’s Open Textbook Challenge for public release under a Creative Commons Attribution ( CC BY ) license.