

The other natural numbers (greater than one), are called composite numbers, and are the products of prime numbers.


This method, of listing primes, is called a “sieve” because it is like taking all of the numbers (up to some maximum) and running them through a sieve to separate out all of the primes.Ī prime number (such as 2 or 3 or 5) is a natural number (positive whole number) which is only divisible by itself and one (and no other natural number). He is also the man who first measured the circumference of the earth. The Sieve of Eratosthenes is named after the Greek mathematician Eratosthenes (276-196 BC), from Alexandria, who invented it. Here is the output from the program: 1 2 3 5 7 11 13 17 19 At the end of this section of code (Line 22), sieve() is called with x+2, making sure only odd numbers are processed. For example if x = 3, then 6, 9, 12, etc. All multiples of j are marked in p by setting them to zero.
