
PRIME numbers may have been studied for over 2000 years, but there is always something new to learn. A method for finding primes first devised by the ancient Greek mathematician Eratosthenes in 240 BC has had a 21st century upgrade.
Prime numbers are divisible only by themselves and 1, and form the building blocks of all other numbers – multiplying different primes creates the rest of the whole numbers.
The Sieve of Eratosthenes, as it is known, lets you find all prime numbers less than a certain number by sequentially sieving out multiples of primes.
Advertisement
For example, for the numbers 1 to 100, you would begin by removing all multiples of 2, the first prime number – so 4, 6, 8 and so on. You would then start again from the next smallest number, removing multiples of 3. Each number you begin the process on – a number that hasn’t already been removed – is prime.
The sieve works well for finding small primes, but becomes unworkable for very large ones because of the time and computer memory required.
In the 1960s, when computers had far less memory than they do now, mathematicians optimised the sieve so that they could find all prime numbers up to a certain number, N, while using only √N units of storage space. For example, to find all the prime numbers up to 100, an algorithm could store and process numbers in rows of 10.
But that isn’t practical for much larger values of N. “You can’t do that for a billion numbers using only 10 units of space at a time, because the algorithm becomes very inefficient,” says Harald Helfgott at the University of Göttingen in Germany, who has upgraded the method.
His work uses Diophantine approximation, where real numbers – essentially any point on the number line, including decimals – can be approximated by rational numbers – those that can be expressed as a fraction of two whole numbers. Pi, for example, is a real number that can be approximated by the fraction 355/113.
This lets Helfgott sieve across a range of numbers at the same time, making the process more efficient. To find all primes less than a number N, the algorithm requires less computer memory – about N1/3(log N)2/3 units of storage space. It would let you sieve a billion numbers with around 7500 units of memory compared with about 32,000 for the existing method (Mathematics of Computation, ).
Helfgott’s approach can also be used to factorise very large numbers, breaking them down into prime building blocks. It is not yet clear if Helfgott’s approach will be practically useful, as he has not optimised his algorithm.
“How much of a difference it makes in practice we will only know once real programmers implement the program and spend time optimising it,” he says.
Article amended on 16 May 2019
We corrected the reason for the gains being purely theoretical