# Euclid's theorem

Euclid's theorem is a fundamental statement in number theory that asserts that there are infinitely many prime numbers. It was first proven by Euclid in his work Elements. There are several proofs of the theorem.

## Euclid's proof

Euclid offered a proof published in his work Elements (Book IX, Proposition 20), which is paraphrased here.
Consider any finite list of prime numbers p$_1$, p$_2$, ..., p$_n$. It will be shown that there exists at least one additional prime number not included in this list. Let P be the product of all the prime numbers in the list: P = p$_1$p$_2$...p$_n$. Let q = P + 1. Then q is either prime or not:
* If q is prime, then there is at least one more prime that is not in the list, namely, q itself.
* If q is not prime, then some prime factor p divides q. If this factor p were in our list, then it would also divide P (since P is the product of every number in the list). If p divides P and q, then p must also divide the difference of the two numbers, which is (P + 1) − P or just 1. Since no prime number divides 1, p cannot be in the list. This means that at least one more prime number exists that is not in the list.
This proves that for every finite list of prime numbers there is a prime number not in the list. In the original work, Euclid denoted the arbitrary finite set of prime numbers as A, B, Γ.
Euclid is often erroneously reported to have proved this result by contradiction beginning with the assumption that the finite set initially considered contains all prime numbers, though it is actually a proof by cases, a direct proof method. The philosopher Torkel Franzén, in a book on logic, states, "Euclid's proof that there are infinitely many primes is not an indirect proof [...] The argument is sometimes formulated as an indirect proof by replacing it with the assumption 'Suppose q$_1$, ..., q$_n$ are all the primes'. However, since this assumption isn't even used in the proof, the reformulation is pointless."

### Variations

Several variations on Euclid's proof exist, including the following:
The factorial n! of a positive integer n is divisible by every integer from 2 to n, as it is the product of all of them. Hence, n! + 1 is not divisible by any of the integers from 2 to n, inclusive (it gives a remainder of 1 when divided by each). Hence n! + 1 is either prime or divisible by a prime larger than n. In either case, for every positive integer n, there is at least one prime bigger than n. The conclusion is that the number of primes is infinite.

## Euler's proof

Another proof, by the Swiss mathematician Leonhard Euler, relies on the fundamental theorem of arithmetic: that every integer has a unique prime factorization. What Euler wrote (not with this modern notation and, unlike modern standards, not restricting the arguments in sums and products to any finite sets of integers) is equivalent to the statement that we have
$\prod _{p\in P_{k}}{\frac {1}{1-{\frac {1}{p}}}}=\sum _{n\in N_{k}}{\frac {1}{n}},$
where $P_{k}$ denotes the set of the k first prime numbers, and $N_{k}$ is the set of the positive integers whose prime factors are all in $P_{k}.$
To show this, one expands each factor in the product as a geometric series, and distributes the product over the sum (this is a special case of the Euler product formula for the Riemann zeta function).
${\begin{aligned}\prod _{p\in P_{k}}{\frac {1}{1-{\frac {1}{p}}}}&=\prod _{p\in P_{k}}\sum _{i\geq 0}{\frac {1}{p^{i}}}\\&=\left(\sum _{i\geq 0}{\frac {1}{2^{i}}}\right)\cdot \left(\sum _{i\geq 0}{\frac {1}{3^{i}}}\right)\cdot \left(\sum _{i\geq 0}{\frac {1}{5^{i}}}\right)\cdot \left(\sum _{i\geq 0}{\frac {1}{7^{i}}}\right)\cdots \\&=\sum _{\ell ,m,n,p,\ldots \geq 0}{\frac {1}{2^{\ell }3^{m}5^{n}7^{p}\cdots }}\\&=\sum _{n\in N_{k}}{\frac {1}{n}}.\end{aligned}}$
In the penultimate sum, every product of primes appears exactly once, so the last equality is true by the fundamental theorem of arithmetic. In his first corollary to this result Euler denotes by a symbol similar to $\infty$ the "absolute infinity" and writes that the infinite sum in the statement equals the "value" $\log \infty$, to which the infinite product is thus also equal (in modern terminology this is equivalent to saying that the partial sum up to $x$ of the harmonic series diverges asymptotically like $\log x$). Then in his second corollary, Euler notes that the product
$\prod _{n\geq 2}{\frac {1}{1-{\frac {1}{n^{2}}}}}$
converges to the finite value 2, and there are consequently more primes than squares. This proves Euclid's Theorem.
In the same paper (Theorem 19) Euler in fact used the above equality to prove a much stronger theorem that was unknown before him, namely that the series
$\sum _{p\in P}{\frac {1}{p}}$
is divergent, where P denotes the set of all prime numbers (Euler writes that the infinite sum equals $\log \log \infty$, which in modern terminology is equivalent to saying that the partial sum up to $x$ of this series behaves asymptotically like $\log \log x$).

## Erdős's proof

Paul Erdős gave a proof that also relies on the fundamental theorem of arithmetic. Every positive integer has a unique factorization into a square-free number r and a square number s$^2$. For example, 75,600 = 2$^4$ 3$^3$ 5$^2$ 7$^1$ = 21 ⋅ 60$^2$.
Let N be a positive integer, and let k be the number of primes less than or equal to N. Call those primes p$_1$, ... , p$_k$. Any positive integer a which is less than or equal to N can then be written in the form
$a=\left(p_{1}^{e_{1}}p_{2}^{e_{2}}\cdots p_{k}^{e_{k}}\right)s^{2},$
where each e$_i$ is either 0 or 1. There are 2$^k$ ways of forming the square-free part of a. And s$^2$ can be at most N, so s ≤ √N. Thus, at most 2$^k$ √N numbers can be written in this form. In other words,
$N\leq 2^{k}{\sqrt {N}}.$
Or, rearranging, k, the number of primes less than or equal to N, is greater than or equal to ⁠1/2⁠log$_2$ N. Since N was arbitrary, k can be as large as desired by choosing N appropriately.

## Furstenberg's proof

In the 1950s, Hillel Furstenberg introduced a proof by contradiction using point-set topology.
Define a topology on the integers Z{\textstyle \mathbb {Z} }, called the evenly spaced integer topology, by declaring a subset U⊆Z{\textstyle U\subseteq \mathbb {Z} } to be an open set if and only if it is either the empty set, ∅{\textstyle \emptyset }, or it is a union of arithmetic sequences S(a, b){\textstyle S(a, b)} (for a≠0{\textstyle a\neq 0}), where
$S(a,b)=\{an+b\mid n\in \mathbb {Z} \}=a\mathbb {Z} +b.$
Then a contradiction follows from the property that a finite set of integers cannot be open and the property that the basis sets S(a, b){\textstyle S(a, b)} are both open and closed, since
$\mathbb {Z} \setminus \{-1,+1\}=\bigcup _{p{\text{ prime}}}S(p,0)$
cannot be closed because its complement is finite, but is closed since it is a finite union of closed sets.

## Recent proofs
### Proof using the inclusion-exclusion principle

Juan Pablo Pinasco has written the following proof.
Let p$_1$, ..., p$_N$ be the smallest N primes. Then by the inclusion–exclusion principle, the number of positive integers less than or equal to x that are divisible by one of those primes is
${\begin{aligned}1+\sum _{i}\left\lfloor {\frac {x}{p_{i}}}\right\rfloor -\sum _{i<j}\left\lfloor {\frac {x}{p_{i}p_{j}}}\right\rfloor &+\sum _{i<j<k}\left\lfloor {\frac {x}{p_{i}p_{j}p_{k}}}\right\rfloor -\cdots \\&\cdots \pm (-1)^{N+1}\left\lfloor {\frac {x}{p_{1}\cdots p_{N}}}\right\rfloor .\qquad (1)\end{aligned}}$
Dividing by x and letting x → ∞ gives
$\sum _{i}{\frac {1}{p_{i}}}-\sum _{i<j}{\frac {1}{p_{i}p_{j}}}+\sum _{i<j<k}{\frac {1}{p_{i}p_{j}p_{k}}}-\cdots \pm (-1)^{N+1}{\frac {1}{p_{1}\cdots p_{N}}}.\qquad (2)$
This can be written as
$1-\prod _{i=1}^{N}\left(1-{\frac {1}{p_{i}}}\right).\qquad (3)$
If no other primes than p$_1$, ..., p$_N$ exist, then the expression in (1) is equal to $\lfloor x\rfloor$ and the expression in (2) is equal to 1, but clearly the expression in (3) is not equal to 1. Therefore, there must be more primes than p$_1$, ..., p$_N$.

### Proof using Legendre's formula

In 2010, Junho Peter Whang published the following proof by contradiction. Let k be any positive integer. Then according to Legendre's formula (sometimes attributed to de Polignac)
$k!=\prod _{p{\text{ prime}}}p^{f(p,k)}$
where
$f(p,k)=\left\lfloor {\frac {k}{p}}\right\rfloor +\left\lfloor {\frac {k}{p^{2}}}\right\rfloor +\cdots .$
$f(p,k)<{\frac {k}{p}}+{\frac {k}{p^{2}}}+\cdots ={\frac {k}{p-1}}\leq k.$
But if only finitely many primes exist, then
$\lim _{k\to \infty }{\frac {\left(\prod _{p}p\right)^{k}}{k!}}=0,$
(the numerator of the fraction would grow singly exponentially while by Stirling's approximation the denominator grows more quickly than singly exponentially), contradicting the fact that for each k the numerator is greater than or equal to the denominator.

### Proof by construction

Filip Saidak gave the following proof by construction, which does not use reductio ad absurdum or Euclid's lemma (that if a prime p divides ab then it must divide a or b).
Since each natural number greater than 1 has at least one prime factor, and two successive numbers n and (n + 1) have no factor in common, the product n(n + 1) has more different prime factors than the number n itself. So the chain of pronic numbers: 1×2 = 2 {2}, 2×3 = 6 {2, 3}, 6×7 = 42 {2, 3, 7}, 42×43 = 1806 {2, 3, 7, 43}, 1806×1807 = 3263442 {2, 3, 7, 43, 13, 139}, · · · provides a sequence of unlimited growing sets of primes.

### Proof using the incompressibility method

Suppose there were only k primes (p$_1$, ..., p$_k$). By the fundamental theorem of arithmetic, any positive integer n could then be represented as
$n={p_{1}}^{e_{1}}{p_{2}}^{e_{2}}\cdots {p_{k}}^{e_{k}},$
where the non-negative integer exponents e$_i$ together with the finite-sized list of primes are enough to reconstruct the number. Since $p_{i}\geq 2$ for all i, it follows that $e_{i}\leq \lg n$ for all i (where $\lg$ denotes the base-2 logarithm). This yields an encoding for n of the following size (using big O notation): $O({\text{prime list size}}+k\lg \lg n)=O(\lg \lg n)$ bits. This is a much more efficient encoding than representing n directly in binary, which takes $N=O(\lg n)$ bits. An established result in lossless data compression states that one cannot generally compress N bits of information into fewer than N bits. The representation above violates this by far when n is large enough since $\lg \lg n=o(\lg n)$. Therefore, the number of primes must not be finite.

### Proof using an even-odd argument

Romeo Meštrović used an even-odd argument to show that if the number of primes is not infinite then 3 is the largest prime, a contradiction.
Suppose that $p_{1}=2<p_{2}=3<p_{3}<\cdots <p_{k}$ are all the prime numbers. Consider $P=3p_{3}p_{4}\cdots p_{k}$ and note that by assumption all positive integers relatively prime to it are in the set $S=\{1,2,2^{2},2^{3},\dots \}$. In particular, $2$ is relatively prime to $P$ and so is $P-2$. However, this means that $P-2$ is an odd number in the set $S$, so $P-2=1$ , or $P=3$. This means that $3$ must be the largest prime number which is a contradiction.
The above proof continues to work if $2$ is replaced by any prime $p_{j}$ with $j\in \{1,2,\dots ,k-1\}$, the product $P$ becomes $p_{1}p_{2}\cdots p_{j-1}\cdot p_{j+1}\cdots p_{k}$ and even vs. odd argument is replaced with a divisible vs. not divisible by $p_{j}$ argument. The resulting contradiction is that $P-p_{j}$ must, simultaneously, equal $1$ and be greater than $1$, which is impossible.

## Stronger results

The theorems in this section simultaneously imply Euclid's theorem and other results.

### Dirichlet's theorem on arithmetic progressions

Dirichlet's theorem states that for any two positive coprime integers a and d, there are infinitely many primes of the form a + nd, where n is also a positive integer. In other words, there are infinitely many primes that are congruent to a modulo d.

### Prime number theorem

Let π(x) be the prime-counting function that gives the number of primes less than or equal to x, for any real number x. The prime number theorem then states that x / log x is a good approximation to π(x), in the sense that the limit of the quotient of the two functions π(x) and x / log x as x increases without bound is 1:
$\lim _{x\rightarrow \infty }{\frac {\pi (x)}{x/\log(x)}}=1.$
Using asymptotic notation this result can be restated as
$\pi (x)\sim {\frac {x}{\log x}}.$
This yields Euclid's theorem, since $\lim _{x\rightarrow \infty }{\frac {x}{\log x}}=\infty .$

### Bertrand–Chebyshev theorem

In number theory, Bertrand's postulate is a theorem stating that for any integer $n>1$, there always exists at least one prime number such that $n<p<2n.$ Equivalently, writing $\pi (x)$ for the prime-counting function (the number of primes less than or equal to $x$), the theorem asserts that π(x)−π(x/2)≥1{\textstyle \pi (x)-\pi ({\tfrac {x}{2}})\geq 1} for all $x\geq 2$.
This statement was first conjectured in 1845 by Joseph Bertrand (1822–1900). Bertrand himself verified his statement for all numbers in the interval [2, 3 × 10$^6$]. His conjecture was completely proved by Chebyshev (1821–1894) in 1852 and so the postulate is also called the Bertrand–Chebyshev theorem or Chebyshev's theorem.