## Sieve Of Eratosthenes

A 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). The other natural numbers (greater than one), are called composite numbers, and are the products of prime numbers. One is neither prime nor composite. See my article, The Infinitude Of Primes.

To determine if a number is prime or composite (and list its prime factors), we often have to experiment by dividing by primes from a list of primes. We divide by 2, 3, 5, etc. And if none of these divisions comes out even, then our number is a prime. Let's try 91, which looks like it might be a prime. We try 2, 3, 5, and those don't come out even. But, when we divide by 7, we get 13. So 91=7 x 13, and is composite.

There is a fairly simple method for making a list of primes. We will start with a list of all of the numbers from 2 to 100:

```     2  3  4  5  6  7  8  9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
```

We now make 2 bold (you can circle it), identifying it as prime (it is not divisible by lesser primes), and cross out every second number after 2:

```     2  3  X  5  X  7  X  9  X
11  X 13  X 15  X 17  X 19  X
21  X 23  X 25  X 27  X 29  X
31  X 33  X 35  X 37  X 39  X
41  X 43  X 45  X 47  X 49  X
51  X 53  X 55  X 57  X 59  X
61  X 63  X 65  X 67  X 69  X
71  X 73  X 75  X 77  X 79  X
81  X 83  X 85  X 87  X 89  X
91  X 93  X 95  X 97  X 99  X
```

We have now identified 3 as a prime. It is not divisible by lesser primes. And we cross out every third number after 3. Some of these are already crossed out. I will just skip over those:

```     2  3  X  5  X  7  X  X  X
11  X 13  X  X  X 17  X 19  X
X  X 23  X 25  X  X  X 29  X
31  X  X  X 35  X 37  X  X  X
41  X 43  X  X  X 47  X 49  X
X  X 53  X 55  X  X  X 59  X
61  X  X  X 65  X 67  X  X  X
71  X 73  X  X  X 77  X 79  X
X  X 83  X 85  X  X  X 89  X
91  X  X  X 95  X 97  X  X  X
```

We do the same thing with 5, and then 7:

```     2  3  X  5  X  7  X  X  X
11  X 13  X  X  X 17  X 19  X
X  X 23  X  X  X  X  X 29  X
31  X  X  X  X  X 37  X  X  X
41  X 43  X  X  X 47  X  X  X
X  X 53  X  X  X  X  X 59  X
61  X  X  X  X  X 67  X  X  X
71  X 73  X  X  X  X  X 79  X
X  X 83  X  X  X  X  X 89  X
X  X  X  X  X  X 97  X  X  X
```

And now, we can stop! You may want to go on and try 11. But that is unnecessary. No more numbers will be crossed out, between 2 and 100. Do you see why?

We can stop at the square root of 100, which is 10. The reason for this is that any number less than 100 (91, for example), which is divisible by a number greater than the square root of 100 (13, in this example), is also divisible by a number less than the square root of 100 (7, in this example). So, we have already crossed out all such numbers.

Removing the x's, we have this list of primes:

``` 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
```

This process is called the Sieve of Eratosthenes, after the Greek mathematician, from Alexandria, who invented it. He is also the man who first measured the circumference of the earth. 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. This process works well on a computer, by the way.

Here are the primes less than 1000:

```   2   3   5   7  11  13  17  19  23  29
31  37  41  43  47  53  59  61  67  71
73  79  83  89  97 101 103 107 109 113
127 131 137 139 149 151 157 163 167 173
179 181 191 193 197 199 211 223 227 229
233 239 241 251 257 263 269 271 277 281
283 293 307 311 313 317 331 337 347 349
353 359 367 373 379 383 389 397 401 409
419 421 431 433 439 443 449 457 461 463
467 479 487 491 499 503 509 521 523 541
547 557 563 569 571 577 587 593 599 601
607 613 617 619 631 641 643 647 653 659
661 673 677 683 691 701 709 719 727 733
739 743 751 757 761 769 773 787 797 809
811 821 823 827 829 839 853 857 859 863
877 881 883 887 907 911 919 929 937 941
947 953 967 971 977 983 991 997```