Читать книгу The Number Mysteries: A Mathematical Odyssey through Everyday Life - Marcus Sautoy du - Страница 18
How the Greeks used sieves to cook up the primes
ОглавлениеHere’s a systematic way discovered by the Ancient Greeks which is very effective at finding small primes. The task is to find an efficient method that will knock out all the non-primes. Write down the numbers from 1 to 100. Start by striking out number 1. (As I have mentioned, though the Greeks believed 1 to be prime, in the twenty-first century we no longer consider it to be.) Move to the next number, 2. This is the first prime. Now strike out every second number after 2. This effectively knocks out everything in the 2 times table, eliminating all the even numbers except for 2. Mathematicians like to joke that 2 is the odd prime because it’s the only even prime … but perhaps humour isn’t a mathematician’s strong point.
FIGURE 1.18 Strike out every second number after 2.
Now take the lowest number which hasn’t been struck out, in this case 3, and systematically knock out everything in the 3 times table:
FIGURE 1.19 Now strike out every third number after 3.
Because 4 has already been knocked out, we move next to the number, 5, and strike out every fifth number on from 5. We keep repeating this process, going back to the lowest number n that hasn’t yet been eliminated, and then strike out all the numbers n places ahead of it:
FIGURE 1.20 Finally we are left with the primes from 1 to 100.
The beautiful thing about this process it that it is very mechanical—it doesn’t require much thought to implement. For example, is 91 a prime? With this method you don’t have to think. 91 would have been struck out when you knocked out every 7th number on from 7 because 91=7×13.91 often catches people out because we tend not to learn our 7 times table up to 13.
This systematic process is a good example of an algorithm, a method of solving a problem by applying a specified set of instructions—which is basically what a computer program is. This particular algorithm was discovered two millennia ago in one of the hotbeds of mathematical activity at the time: Alexandria, in present-day Egypt. Back then, Alexandria was one of the outposts of the great Greek empire and boasted one of the finest libraries in the world. It was during the third century BC that the librarian Eratosthenes came up with this early computer program for finding primes.
It is called the sieve of Eratosthenes, because each time you knock out a group of non-primes it is as if you are using a sieve, setting the gaps between the wires of the sieve according to each new prime you move on to. First you use a sieve where the wires are 2 apart. Then 3 apart. Then 5 apart. And so on. The only trouble is that the method soon becomes rather inefficient if you try to use it to find bigger and bigger primes.
As well as sieving for primes and looking after the hundreds of thousands of papyrus and vellum scrolls in the library, Eratosthenes also calculated the circumference of the Earth and the distance of the Earth to the Sun and the Moon. The Sun he calculated to be 804,000,000 stadia from the Earth—although his unit of measurement perhaps makes judging the accuracy a little difficult. What size stadium are we meant to use: Wembley, or something smaller, like Loftus Road?
In addition to measuring the solar system, Eratosthenes charted the course of the Nile and gave the first correct explanation for why it kept flooding: heavy rains at the river’s distant sources in Ethiopia. He even wrote poetry. Despite all this activity, his friends gave him the nickname Beta—because he never really excelled at anything. It is said that he starved himself to death after going blind in old age.
You can use your snakes and ladders board on the cover to put the Sieve of Eratosthenes into operation. Take a pile of pasta and place pieces on each of the numbers as you knock them out. The numbers left uncovered will be the primes.