The evidence is more convincing for the ancient Egyptians, with their heavy emphasis on unit fractions (or Egyptian fractions). The Rhynd mathematical papyrus, dating to four thousand years ago, concerns itself with expressing 2n (with n an odd integer in the range 4<n<102) as a sum of unit fractions. When n is prime, the unit fraction expansions are considerably harder to arrive at when n is prime.

But the ancient Greeks of about twenty-five hundred years ago often get the credit for being the first to study prime numbers for their own sake. Eratosthenes came up with the sieve of Eratosthenes, and Euclid proved many important basic facts about prime numbers which today we take for granted, such as that there are infinitely many primes. Euclid also proved the relationship between the Mersenne primes and the even perfect numbers.

With the Roman conquest of the Greeks, much of the written Greek knowledge was translated to Latin, or at least preserved. As the Greeks taught the Romans what they knew, they preserved Greek mathematical knowledge but made no further progress in the study of pure mathematics, such as prime numbers.

The Arab mathematicians of the Middle Ages studied the work of ancient Greek mathematicians but with the added advantage of a numerical system more amenable to computational work. Thabit ibn Qurra, for example, proved the relationship between consecutive prime Thabit numbers and amicable pairs.

Pierre de Fermat stated an important theorem (now known as Fermat’s little theorem) which states that given a prime p and a coprime base b, the congruencebp-1≡1modp holds true. Fermat also conjectured incorrectly that 22n+1 is always prime (the Fermat primes) while Marin Mersenne incorrectly conjectured that in 2p-1 the primes 67 and 257 give Mersenne primes. Nevertheless these numbers were still named after them.

By this time, the most common definition of prime number was “a number that is divisible by 1 and itself.” 1 fits this definition, but some mathematicians were troubled by the ways in which 1 is different from the other prime numbers. Euler, for example, was motivated by the fact that σ⁢(p)=p+1 for prime p but not for p=1 to regard 1 as not a prime number. Others were no more bothered by 1’s peculiarities than those of the number 2, such as Moritz Stern, who did not consider 3 a Stern prime because he considered 1 prime.

In the 20th century, computers gradually became important in calculating data for theorists to ponder; from the 13th Mersenne prime on all the largest primes since the middle of the century have been found with the help of computers. The invention of public key cryptography in the late 1970s has precipitated the need for larger prime numbers and motivated many advances in integer factorization algorithms. From the 1990s onwards, distributed computing projects like the Great Internet Mersenne Prime Search and Seventeen or Bust have discovered some of the largest known prime numbers.