Discrete Mathematics and Proof

There are infinitely many primes

The primes thin out as the numbers grow. Do they ever stop?

Where you are 8 in Introductory number theory

Why this exists

A prime is an integer greater than 1 whose only positive divisors are 1 and itself. The sieve shows them thinning out: 25 primes below 100, only 21 between 100 and 200, and stretches with no prime as long as you like (Existence proof builds them). Perhaps the primes run out, and some largest prime exists.

No search can settle this, since the question is about what lies beyond any search. It needs an argument about every finite list of primes at once. The standard one is over two thousand years old, it is often a reader’s first real Proof by contradiction, and its idea, “multiply and add one”, reaches well past where it started. Day 2 pushes it to primes of a special form and to a bound on the size of the nth prime.

Definition

A set is finite if its elements can be written as a list a_1, a_2, \ldots, a_k for some whole number k; otherwise it is infinite. The statement of this lesson is

\text{The set of primes is infinite.}

Equivalently: for every finite list of primes there is a prime that is not on the list.

The primes in increasing order are p_1 = 2, p_2 = 3, p_3 = 5, and so on, so p_n is the nth prime. For a positive integer n, n! = 1 \cdot 2 \cdot 3 \cdots n.

An integer has the form 4k + 3 if it equals 4k + 3 for some integer k, that is, if it leaves remainder 3 on division by 4. The forms 4k + 1, 6k + 1 and 6k + 5 read the same way.

Intuition

Day 1: one more than a multiple of everything

Multiply a finite list of primes together. The product is a multiple of each of them, so the product plus 1 leaves remainder 1 on division by each, and none of them divides it. But the new number is at least 2, so some prime divides it, and that prime was left off the list.

The argument does not say the new number is prime, and it does not say the missing prime is larger than the listed ones. It says only that some prime dividing the new number is missing.

Day 2: sorting the primes into columns

Divide an integer by 4 and the remainder is 0, 1, 2 or 3, so every integer sits in one of four columns.

0 1 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
4k
4k + 1
4k + 2
4k + 3
Figure 1The integers sorted by remainder on division by 4, primes shaded. Apart from 2, every prime lies in the column 4k + 1 or the column 4k + 3.

The columns 4k and 4k + 2 hold only even numbers, so their only prime is 2. Every other prime lies in the column 4k + 1 or 4k + 3. Day 2 asks whether each of these holds infinitely many primes. The multiply-and-adjust idea answers for one column and not, by itself, for the other.

Results

Day 1

Lemma 1. Every integer n \ge 2 has a prime divisor. In fact the least divisor of n that is greater than 1 is prime.

Theorem 1 (the list form). For every finite list of primes p_1, p_2, \ldots, p_k, every prime divisor of p_1 p_2 \cdots p_k + 1 is a prime not on the list, and such a prime exists.

Theorem 2. There are infinitely many primes.

The argument is in the spirit of Euclid’s Elements, Book IX, Proposition 20, which states that the primes are more than any assigned multitude of primes.

A companion result. \displaystyle \sqrt{2} is irrational. It is the other classic first proof by contradiction, proved in full with \displaystyle \sqrt{3} beside it in Proof by contradiction, and not proved again here.

Day 2

Lemma 2. A product of integers of the form 4k + 1 has the form 4k + 1.

Lemma 3. Every positive integer of the form 4k + 3 has a prime divisor of the form 4k + 3.

Theorem 3. There are infinitely many primes of the form 4k + 3.

Theorem 4 (a bound). For every n \ge 1,

p_n \le 2^{2^{n-1}}

Stated without proof. There are infinitely many primes of the form 4k + 1. More generally, if positive integers a and b have no common divisor greater than 1, there are infinitely many primes of the form ak + b. This is Dirichlet’s theorem on primes in arithmetic progressions; its proof uses analysis well beyond this lesson.

Why it is true

Day 1

Proof of Lemma 1. Let n \ge 2. The divisors of n greater than 1 include n itself and all lie among the finitely many integers 2, 3, \ldots, n, so there is a least one, d. Suppose, for contradiction, that d is not prime. Then d = ab with 1 < a < d. Since a \mid d and d \mid n, the transitive property of divisibility gives a \mid n. So a is a divisor of n greater than 1 and less than d, contradicting the choice of d. So d is prime. \square

Finding a least element was safe because the set was finite. Every nonempty set of positive integers has a least element, finite or not; that principle, well-ordering, belongs to Strong induction and well-ordering.

Proof of Theorem 1. Let N = p_1 p_2 \cdots p_k + 1. Each p_i \ge 2, so N \ge 3, and by Lemma 1 N has a prime divisor. Let q be any prime divisor of N, and suppose, for contradiction, that q = p_i for some i. Then q divides the product p_1 p_2 \cdots p_k, being one of its factors, and q divides N. A divisor of two integers divides their difference (Proving statements about divisibility), so

q \mid N - p_1 p_2 \cdots p_k = 1

But no integer greater than 1 divides 1. So q is not on the list. \square

This is a direct construction: from any list it produces a prime off it. The contradiction inside is only the small step showing q differs from each p_i.

Proof of Theorem 2. Suppose, for contradiction, that there are only finitely many primes, and list all of them: p_1, \ldots, p_k. By Theorem 1 some prime is not on this list, yet the list held every prime. So the set of primes is infinite. \square

Day 2

Proof of Lemma 2. Let x = 4a + 1 and y = 4b + 1 with a, b integers. Then

\begin{aligned} xy &= 16ab + 4a + 4b + 1 \\ &= 4(4ab + a + b) + 1 \end{aligned}

and 4ab + a + b is an integer. For more factors, multiply them in one at a time: each partial product has the form 4k + 1, so the two-factor case applies again. \square

Proof of Lemma 3. Let N be a positive integer of the form 4k + 3. Its divisors of the form 4k + 3 include N and lie among 1, \ldots, N, so there is a least one, d \ge 3. Suppose, for contradiction, that d is not prime: d = ab with 1 < a, b < d. Since d is odd, so are a and b (a product with an even factor is even, Proving statements about even and odd numbers). An odd integer leaves remainder 1 or 3 on division by 4. If a and b both had the form 4k + 1, so would d, by Lemma 2, and an integer has only one remainder on division by 4. So one of them, say a, has the form 4k + 3. Then a \mid d and d \mid N, so a is a divisor of N of the form 4k + 3 smaller than d, a contradiction. So d is prime. \square

Proof of Theorem 3. Suppose, for contradiction, that the primes of the form 4k + 3 are finitely many, and list them all: q_1, \ldots, q_m. The list is not empty, since 3 = 4 \cdot 0 + 3. Let

N = 4 q_1 q_2 \cdots q_m - 1

Then N = 4(q_1 q_2 \cdots q_m - 1) + 3 has the form 4k + 3, and N \ge 11. By Lemma 3, N has a prime divisor q of the form 4k + 3, which must be some q_i. Then q divides 4 q_1 \cdots q_m and N, so q \mid 4 q_1 \cdots q_m - N = 1, which is impossible. \square

Why the same proof fails for 4k + 1. List the primes r_1, \ldots, r_m of the form 4k + 1 and take N = 4 r_1 \cdots r_m + 1, of the form 4k + 1. The proof would need an analog of Lemma 3, that an integer of the form 4k + 1 has a prime divisor of that form. That is false: a product of two integers of the form 4k + 3 has the form 4k + 1 (Exercise 17), so every prime factor of N can be of the form 4k + 3 (Example 5). The theorem for 4k + 1 is true, but its proof needs a different number and facts from Modular arithmetic.

Proof of Theorem 4. Write P_n = p_1 p_2 \cdots p_n.

First, p_{n+1} \le P_n + 1. By Theorem 1, P_n + 1 has a prime divisor q that is not among p_1, \ldots, p_n. A positive divisor of a positive integer is at most that integer, so q \le P_n + 1, and q is a prime other than the first n, so q \ge p_{n+1}.

Next, P_n \le 2^{2^n - 1} for every n \ge 1, by induction. For n = 1, P_1 = 2 = 2^1. Assume P_n \le 2^{2^n - 1}. Since 1 \le 2^{2^n - 1},

\begin{aligned} p_{n+1} &\le P_n + 1 \\ &\le 2^{2^n - 1} + 2^{2^n - 1} \\ &= 2^{2^n} \end{aligned}

and so P_{n+1} = P_n \, p_{n+1} is at most 2^{2^n - 1} \cdot 2^{2^n}, which is 2^{2^{n+1} - 1}. That completes the induction. The display above is the theorem for n + 1 \ge 2, and p_1 = 2 = 2^{2^0} is the case n = 1. \square

Worked examples

Examples 1 to 3 go with Day 1, Examples 4 to 6 with Day 2.

Example 1

A list and the number it produces

Apply Theorem 1 to the list 2, 7, 13. Which primes does it produce, and are they larger than the listed ones?

Solution

The product is 2 \cdot 7 \cdot 13 = 182, so N = 183. Its digits add to 12, a multiple of 3, so 183 = 3 \cdot 61. And 61 is prime: \displaystyle \sqrt{61} < 8, and 61 is not divisible by 2, 3, 5 or 7. So the prime divisors are 3 and 61, neither on the list. Directly, 183 = 13 \cdot 14 + 1, so 13 leaves remainder 1, and so do 2 and 7.

The prime 61 is larger than every listed prime, but 3 is smaller than 7 and 13. Theorem 1 promises a prime off the list, not a larger one. Nor is N promised to be prime: here it is 3 \cdot 61, and Counterexample shows it can be composite even when the list is all the primes up to 13.

Example 2

A prime larger than n

Show that for every positive integer n, every prime divisor of n! + 1 is greater than n. Find the prime divisors of 6! + 1.

Solution

Proof. Since n! + 1 \ge 2, Lemma 1 gives a prime divisor; let q be any one. Suppose, for contradiction, that q \le n. Then q is one of the factors of n!, so q \mid n!. Also q \mid n! + 1, so q divides (n! + 1) - n! = 1, impossible. So q > n. \square

For n = 6, 6! + 1 = 721 = 7 \cdot 103, and 103 is prime (not divisible by 2, 3, 5 or 7, and 11^2 > 103). Both exceed 6.

Levin’s proof of Theorem 2 uses this number: if p were the largest prime, a prime divisor of p! + 1 would be larger than p. Unlike Theorem 1, this always produces a larger prime.

Example 3

Subtracting one instead

Let p_1, \ldots, p_k be different primes, the list neither empty nor just the prime 2. Prove that every prime divisor of p_1 p_2 \cdots p_k - 1 is off the list. What goes wrong for the list 2 alone?

Solution

The +1 proof used two facts: the number is at least 2, and a listed prime divides the number’s difference from a product containing it. The second survives the change of sign. The first needs checking.

Proof. Let M = p_1 p_2 \cdots p_k - 1. Two or more different primes include an odd one, and a single prime other than 2 is odd, so some factor is at least 3 and every factor is at least 2. So the product is at least 3 and M \ge 2, and Lemma 1 gives a prime divisor q. If q = p_i, then q \mid p_1 \cdots p_k and q \mid M, so q \mid p_1 \cdots p_k - M = 1, a contradiction. \square

For the list 3, 11: 33 - 1 = 32 = 2^5, and 2 is off the list. For the list 2 alone: 2 - 1 = 1, which has no prime divisor, so the proof fails at “M \ge 2”.

Example 4

Running the 4k + 3 construction

Apply the proof of Theorem 3 to the list 3, 7, 11. Factor N and say which factor the proof points at.

Solution

Each prime has the form 4k + 3: 3 = 4 \cdot 0 + 3, 7 = 4 \cdot 1 + 3, 11 = 4 \cdot 2 + 3. The product is 231, so

N = 4 \cdot 231 - 1 = 923

which is 4 \cdot 230 + 3. Trying primes, 923 = 13 \cdot 71, where 13 = 4 \cdot 3 + 1 and 71 = 4 \cdot 17 + 3. Lemma 3 promised a prime factor of the form 4k + 3, and 71 is it, off the list as the proof predicts. The factor 13 shows why Lemma 3 was needed: a number of the form 4k + 3 can have prime factors of the form 4k + 1, just not only those.

Example 5

When the construction finds nothing new

Run the same construction for the form 4k + 1, starting from the list 5, 17: let N = 4 \cdot 5 \cdot 17 + 1. Factor N and explain what this shows about the argument.

Solution

Both primes qualify: 5 = 4 \cdot 1 + 1 and 17 = 4 \cdot 4 + 1. Then

N = 4 \cdot 85 + 1 = 341 = 11 \cdot 31

with 11 = 4 \cdot 2 + 3 and 31 = 4 \cdot 7 + 3. Both prime factors have the form 4k + 3, and their product 341 has the form 4k + 1, as Exercise 17 predicts.

The construction still produced primes off the list, since Theorem 1 applies to any list. It did not produce a new prime of the form 4k + 1. The broken step is Lemma 3: 341 shows no such lemma holds for 4k + 1. The theorem for 4k + 1 is true, but this argument does not reach it.

Example 6

What the bound says, and how weak it is

Tabulate the bound p_n \le 2^{2^{n-1}} for n = 1 to 5 beside the true primes. Then say how many primes it guarantees up to 1{,}000{,}000, and compare: there are 78{,}498.

Solution
np_n2^{2^{n-1}}
122
234
3516
47256
51165{,}536

Each bound is the square of the one before, since 2^{2^n} = \left(2^{2^{n-1}}\right)^2.

If 2^{2^{n-1}} \le x, then p_1 < p_2 < \cdots < p_n \le x, so there are at least n primes up to x. Since 2^{16} = 65{,}536 \le 1{,}000{,}000 < 2^{32}, the theorem guarantees at least 5 primes up to a million, and no more. Five against 78{,}498: the bound is very weak. Its value is that the same short argument, plus induction, turns “there is always another prime” into a statement about how far to look.

Boundaries

The new number need not be prime. p_1 \cdots p_k + 1 is sometimes prime and sometimes not (183 = 3 \cdot 61). The theorem concerns its prime divisors.

The missing prime need not be large. For an arbitrary list it can be smaller than the listed primes (3 in Example 1). It exceeds them all when the list is all the primes up to p_k (Exercise 12).

Lemma 1 needs n \ge 2. The integer 1 has no prime divisor, and every construction here first checks that its number is at least 2; Example 3 fails for the list 2 exactly there.

The form matters on Day 2. Theorem 3 rests on Lemma 3, special to 4k + 3. The same shape works for 6k + 5 (Exercise 19) but not for 4k + 1 or 6k + 1 without new ideas.

Infinitely many is not a formula. No proof here gives a formula for p_n or an exact count of primes up to x; Theorem 4 is a weak upper bound.

Where this goes next

Lemma 1 is the first half of the fundamental-theorem-of-arithmetic: applied again and again, it writes every integer above 1 as a product of primes, and that theorem adds that the product is unique. The least-element step becomes well-ordering in Strong induction and well-ordering. Remainders on division by 4 and 6 start Modular arithmetic, where primes of the form 4k + 1 can be handled. Building an object that differs from every item on a given list returns in existence proofs and in Cantor’s arguments about sizes of infinite sets.

Exercises

Day 1: running the construction

  1. Find the prime divisors of 3 \cdot 5 \cdot 7 + 1, and check that none is on the list 3, 5, 7.
  2. Is 2 \cdot 3 \cdot 7 + 1 prime?
  3. Apply Theorem 1 to the list 5, 11. Find every prime divisor of the number it produces, and compare their sizes with 5 and 11.
  4. Find the least divisor of 2021 that is greater than 1, and show that it is prime.
  5. Find the prime divisors of 7! + 1, and check that they are greater than 7.
  6. Factor 2 \cdot 3 \cdot 5 \cdot 7 - 1, and check the conclusion of Example 3.

Day 1: reasoning

  1. Let N = p_1 p_2 \cdots p_k + 1. Explain why each p_i leaves remainder 1 when N is divided by it.
  2. Prove that no integer d \ge 2 divides two consecutive integers m and m + 1.
  3. Prove that for every integer n \ge 3, every prime divisor of n! - 1 is greater than n, and deduce that there are infinitely many primes. What happens at n = 2?
  4. Anvar argues: “The number p_1 p_2 \cdots p_k + 1 is not divisible by any p_i, so it is prime.” Find the flaw, and give a list of primes, not the one in Example 1, for which his conclusion is false.
  5. Explain why Theorem 1 implies Theorem 2, and what Theorem 1 says that Theorem 2 does not.
  6. Let p_1, \ldots, p_k be the first k primes. Prove that every prime divisor of p_1 p_2 \cdots p_k + 1 is greater than p_k.

Day 2: forms and constructions

  1. Write 9 \cdot 13 \cdot 17 in the form 4k + 1, and say which lemma predicts this.
  2. Apply the proof of Theorem 3 to the list 3, 7, 19. Factor N, and name a prime of the form 4k + 3 not on the list.
  3. Apply the 4k + 1 attempt to the list 5, 13 by factoring 4 \cdot 5 \cdot 13 + 1. Does a new prime of the form 4k + 1 appear? Does that rescue the argument?
  4. Tabulate p_n and 2^{2^{n-1}} for n = 1 to 6, and find the least n for which the bound exceeds a million.

Day 2: reasoning

  1. Prove that a product of two integers of the form 4k + 3 has the form 4k + 1.
  2. Prove that a product of two integers of the form 6k + 1 has the form 6k + 1.
  3. Prove that there are infinitely many primes of the form 6k + 5.
  4. Prove that p_{n+1} \le p_n! + 1 for every n \ge 1.
  5. Explain why the proof of Theorem 3 fails with N = 4 q_1 \cdots q_m + 3 when 3 is on the list, using the list 3, 7, and say how to repair it.
  6. Prove that every prime other than 2 has the form 4k + 1 or 4k + 3.
Answers
  1. 106 = 2 \cdot 53, and 53 is prime (2, 3, 5, 7 do not divide it, and 8^2 > 53). Neither 2 nor 53 is on the list.
  2. Yes. It is 43, not divisible by 2, 3 or 5, and 7^2 > 43.
  3. 5 \cdot 11 + 1 = 56 = 2^3 \cdot 7. The prime divisors 2 and 7 are off the list and both smaller than 11; 2 is smaller than 5 too.
  4. 43. No prime from 2 to 41 divides 2021, and 2021 = 43 \cdot 47. It is prime by Lemma 1, or directly: 2, 3, 5 do not divide 43, and 7^2 > 43.
  5. 7! + 1 = 5041 = 71^2, so the only prime divisor is 71 > 7.
  6. 210 - 1 = 209 = 11 \cdot 19. Both primes are off the list 2, 3, 5, 7, as Example 3 says.
  7. N = p_i Q + 1, with Q the product of the other primes. Since 0 \le 1 < p_i, the remainder is 1.
  8. If d \mid m and d \mid m + 1, then d divides (m + 1) - m = 1, but no integer d \ge 2 divides 1. \square
  9. For n \ge 3, n! - 1 \ge 5 has a prime divisor q. If q \le n, then q \mid n! and q \mid n! - (n! - 1) = 1, impossible; so q > n. Every n \ge 3 thus has a prime above it, so there is no largest prime. At n = 2, 2! - 1 = 1 has no prime divisor.
  10. Not being divisible by the listed primes does not rule out an unlisted prime divisor. For the list 3, 5: 3 \cdot 5 + 1 = 16 = 2^4, not prime.
  11. If the primes were finite, list them all; Theorem 1 gives a prime off that list, a contradiction. Theorem 1 also says where to find a missing prime: among the prime divisors of p_1 \cdots p_k + 1.
  12. By Theorem 1 a prime divisor q is not among p_1, \ldots, p_k, which are all the primes up to p_k. So q > p_k. \square
  13. 1989 = 4 \cdot 497 + 1, by Lemma 2, since 9 = 4 \cdot 2 + 1, 13 = 4 \cdot 3 + 1 and 17 = 4 \cdot 4 + 1. (Lemma 2 does not need prime factors.)
  14. N = 4 \cdot 399 - 1 = 1595 = 5 \cdot 11 \cdot 29. The prime 11 = 4 \cdot 2 + 3 is off the list; 5 and 29 have the form 4k + 1.
  15. 261 = 3^2 \cdot 29, and 29 = 4 \cdot 7 + 1 is new. No rescue: a proof must work for every list, and Example 5 is a list where no such prime appears.
  16. Bounds: 2, 4, 16, 256, 65{,}536 and 2^{32} = 4{,}294{,}967{,}296, against p_n = 2, 3, 5, 7, 11, 13. The least such n is n = 6.
  17. (4a + 3)(4b + 3) expands to 16ab + 12a + 12b + 9, which is 4(4ab + 3a + 3b + 2) + 1 with 4ab + 3a + 3b + 2 an integer. \square
  18. (6a + 1)(6b + 1) expands to 36ab + 6a + 6b + 1, which is 6(6ab + a + b) + 1 with 6ab + a + b an integer. \square
  19. Suppose the primes of the form 6k + 5 are r_1, \ldots, r_m (5 is one). Let N = 6 r_1 \cdots r_m - 1, which is 6(r_1 \cdots r_m - 1) + 5. Neither 2 nor 3 divides N, so neither divides any divisor of N; and an integer with remainder 0, 2, 3 or 4 on division by 6 is divisible by 2 or 3, so every divisor of N has the form 6k + 1 or 6k + 5. Let d be the least divisor of N of the form 6k + 5. If d = ab with 1 < a, b < d, Exercise 18 forces one factor to have the form 6k + 5, smaller than d, a contradiction. So d is prime, d = r_i, and d \mid 6 r_1 \cdots r_m - N = 1, impossible. \square
  20. By Example 2 with n = p_n, a prime divisor q of p_n! + 1 has q > p_n, and q \le p_n! + 1. A prime above p_n is at least p_{n+1}, so p_{n+1} \le q \le p_n! + 1. \square
  21. With 3 listed, 3 divides 4 q_1 \cdots q_m and 3, so 3 \mid N, and Lemma 3’s prime may be 3 itself. For 3, 7: 4 \cdot 21 + 3 = 87 = 3 \cdot 29, and 29 has the form 4k + 1. Repair: N = 4Q + 3, with Q the product of the listed primes other than 3 (Q = 1 if none). Each prime in Q leaves remainder 1 or 2 on division by 3, and so does a product of such integers (expand as in Lemma 2), so 3 \nmid Q. If 3 \mid N, then 3 \mid N - 3 = 4Q = 3Q + Q, so 3 \mid Q, impossible. If another q_i \mid N, then q_i \mid N - 4Q = 3, impossible. So Lemma 3’s prime is off the list.
  22. Every integer has the form 4k, 4k + 1, 4k + 2 or 4k + 3 (The division algorithm). 4k = 2(2k) and 4k + 2 = 2(2k + 1) are even, and the only even prime is 2. \square
kg1128 · updated 2026-10-22 · CC-BY-SA-4.0