Number Theory

Euclid's Proof That the Primes Never End

Walk through the classic argument that there are infinitely many primes, clear up the usual misreading and compare other proofs.

Key takeaways

  • Given any finite collection of primes, the product of the collection plus 1 has a prime factor outside it.
  • The new number need not be prime itself; only its prime factors are guaranteed to be new.
  • The argument works for any finite list, which is exactly what it means for the primes to be infinite.
  • Variations of the idea prove more, such as infinitely many primes of certain remainder types.

There are infinitely many prime numbers, and Euclid's argument shows why in a few lines. Take any finite list of primes, multiply them all together and add 1. The new number has a prime factor, and that prime cannot be on your list, because dividing the new number by any listed prime leaves remainder 1. So no finite list can contain every prime.

The argument appears as Proposition 20 of Book IX of Euclid's Elements, written around 300 BCE. It is often held up as a model of what a proof can be: short, surprising and complete.

The two facts you need

First, a prime is a whole number greater than 1 divisible only by 1 and itself. Second, every whole number greater than 1 is divisible by at least one prime. To see the second, take the smallest divisor of the number that is bigger than 1. It must be prime, since any smaller divisor of it would also divide the original number.

That is all the machinery. The proof does not even need unique factorization, only the existence of some prime divisor.

The argument

Suppose someone hands you a list of primes p₁, p₂, ..., pₖ and claims it is complete.

N = p₁ × p₂ × ... × pₖ + 1
N > 1, so N has some prime divisor q
dividing N by any pᵢ leaves remainder 1
so q is not any of the pᵢ
q is a prime missing from the list

The claim of completeness is therefore false. Since this works against every finite list, the primes cannot be finite in number.

Euclid's argument against any finite list
1 Take a list Any finite collection of primes 2 Multiply and add 1 Call the result N 3 Find a prime factor N is above 1, so some prime q divides it 4 Check the list Each listed prime leaves remainder 1 5 Conclude q is new, so the list was incomplete Take a list Any finite collection of primes 1 Multiply and add 1 Call the result N 2 Find a prime factor N is above 1, so some prime q divides it 3 Check the list Each listed prime leaves remainder 1 4 Conclude q is new, so the list was incomplete 5

Try it with real numbers

Start with the first few primes and watch what happens.

Primes used N = product + 1 Factorization of N
2 3 3
2, 3 7 7
2, 3, 5 31 31
2, 3, 5, 7 211 211
2, 3, 5, 7, 11 2311 2311
2, 3, 5, 7, 11, 13 30,031 59 × 509

The first five results are prime. The sixth is not. Even so, the proof holds up perfectly: 59 and 509 are primes that were not among the six we started with.

You may also begin with a strange list. Using only 5 and 7, N = 36 = 2² × 3², and both 2 and 3 are new. The list does not have to be the first k primes, or in any order.

A closer look at the remainder step

The one step that needs care is the claim that a listed prime cannot divide N. Call the product of the list P, so that N = P + 1, and pick any prime p on the list.

Suppose p did divide N. Since p also divides P, it would divide the difference N − P, which equals 1. The only positive divisor of 1 is 1, and a prime is larger than 1. So the supposition is impossible.

The same reasoning shows something more general: any two consecutive whole numbers share no prime factor. Everything in Euclid's argument is a use of this plain fact. The cleverness lies in manufacturing a number whose neighbor is divisible by every prime you want to avoid.

Notice too that the list is allowed to repeat nothing and to omit anything. If the list were empty, the empty product would be 1, N would be 2, and the recipe would hand you your first prime.

The most common misreading

Many retellings say "therefore N is prime". That is false, as 30,031 shows. The correct conclusion is that N is divisible by a prime not on the list. That prime might be N itself or something much smaller.

The confusion often comes from a particular phrasing: assume the list contains all primes, form N, note that no listed prime divides it, and conclude that N is prime. Inside the false assumption, that deduction is technically a route to a contradiction. It tells you nothing about numbers built from real lists. Stating the argument as "every finite list misses a prime" avoids the trap.

This also shows that Euclid's argument is not essentially a proof by contradiction. It is a construction: give me any finite set of primes, and here is a recipe for finding another. Euclid himself phrased the result as saying that primes are more numerous than any given multitude of them, and illustrated it with three.

Why adding 1 works

The product of the listed primes is divisible by each of them. Multiples of a prime p are spaced p apart on the number line, so the very next integer after a multiple of p cannot be another one when p is at least 2.

Subtracting 1 works equally well, provided the result is above 1. From 2, 3 and 7 you get 41, a prime. Other constructions also do the job. The number n! + 1, where n! = 1 × 2 × ... × n, leaves remainder 1 on division by every number from 2 to n, so all its prime factors exceed n. That proves there is a prime larger than any n you name.

Building primes one after another

You can run the recipe repeatedly. Start with 2, and at each stage add the smallest prime factor of the product so far plus 1.

2 + 1 = 3                                  new prime 3
2 × 3 + 1 = 7                              new prime 7
2 × 3 × 7 + 1 = 43                         new prime 43
2 × 3 × 7 × 43 + 1 = 1807 = 13 × 139       new prime 13
2 × 3 × 7 × 43 × 13 + 1 = 23,479 = 53 × 443    new prime 53

The list, 2, 3, 7, 43, 13, 53 and so on, is called the Euclid-Mullin sequence. It never repeats a prime. Whether every prime eventually appears is unknown as of the mid-2020s. The numbers grow so fast that factoring them soon becomes the obstacle.

Getting more from the same idea

Small changes prove sharper statements. Consider primes leaving remainder 3 on division by 4, such as 3, 7, 11 and 19. Given a finite list of them, multiply them, multiply by 4 and subtract 1.

The result is odd and leaves remainder 3 on division by 4. A product of numbers leaving remainder 1 still leaves remainder 1, so at least one prime factor must leave remainder 3. No listed prime divides the result. Hence there are infinitely many such primes. The full write-up is in primes of the form 4k + 3.

This trick does not extend to every progression. The general statement, that a, a + d, a + 2d and so on contains infinitely many primes whenever a and d share no factor, is Dirichlet's theorem, and its proof uses much heavier analysis.

Other routes to the same theorem

Mathematicians have found many proofs, each revealing something different.

  • Goldbach's idea. The Fermat numbers 3, 5, 17, 257, 65,537 and onward, each of the form 2 raised to a power of 2, plus 1, share no prime factors with one another. Infinitely many pairwise coprime numbers require infinitely many primes.
  • Consecutive integers. For n above 1, the numbers n and n + 1 share no factor, so n(n + 1) has every prime factor of n and at least one more. Repeating the step produces numbers with ever more primes.
  • Euler's analysis. Euler linked a product over all primes to the harmonic series 1 + 1/2 + 1/3 + ..., which grows without bound. A finite set of primes would give a finite product.

Euler's method does more than count. It shows that the sum of the reciprocals of the primes also diverges, so primes are denser than, for example, the squares. That insight opens analytic number theory, as in the Euler product.

What the proof does not tell you

Euclid shows existence without saying much about location. The new prime lies somewhere between the largest listed prime and N when the list holds all primes up to a point, and that can be an astronomically wide window.

It also says nothing about spacing, twins or patterns. For how many primes there are up to a given size, you need the prime number theorem, proved more than two thousand years later.

Why the style of argument matters

Before this theorem, one might imagine settling the question by looking: compute primes as far as possible and see whether they stop. No amount of computation could ever answer it, since a list that has not yet ended proves nothing about what comes later.

Euclid replaces the search with a guarantee that applies to every list at once, including lists nobody will ever write. The same move, showing that any proposed complete collection can be defeated, reappears throughout mathematics. Cantor's diagonal argument about the real numbers has this shape, taking any proposed list of reals and building one that is missing.

When you read a new proof, it helps to run it on a small example, as the table above does, and then to ask which hypothesis each line uses. Here the only essential inputs are that the list is finite, so that it has a product, and that every number above 1 has a prime divisor. Remove finiteness and the first line can no longer be written. Reading a proof line by line develops this habit.

Test your understanding

Suppose the list is 2, 7 and 11. Then N = 155 = 5 × 31, and both factors are new. Now ask yourself why N could never be divisible by 7 here: 155 = 7 × 22 + 1.

Next, find the flaw in this claim: "Since the product plus 1 is odd whenever 2 is on the list, it is prime." Oddness only rules out the factor 2. The number 2 × 7 + 1 = 15 is odd and composite.

Common questions

Does the proof produce all the primes?

Not as stated. Applied to the first k primes it can skip far ahead, and some primes may be missed. Its job is only to show that something new always exists.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 59 articles in Number Theory →

Latest news on this topic