Eratosthenes' sieve is an algorithm to make a list of primes.

Eratosthenes' sieve

  1. Construct the list L := [2, ..., n] and the empty list M.
  2. Let m be the smallest element in L.
    • Add m to M.
    • Remove all multiples of m from L.
  3. Repeat Step 2 until L is empty.
  4. Return M.


Using this sieve we can find all the primes in the interval [1,n]. The number of such primes can be approximated as follows.

Fact: Prime number theorem

Let prime(n) be the number of primes in the interval [1,n]. Then we have

prime(n) ~ n/log(n)

when n tends to infinity.


The functions prime(n) and n/log(n)