Primes and the Prime Number Theorem: From Infinitude and Unique Factorization to the Law of Distribution
Prerequisite:The Grammar of Mathematics: Reading and Writing Sets and Logic、Introduction to Group Theory: The Axioms, and a Language for Computing with Symmetry
0. Key points
Section titled “0. Key points”- Primes are the atoms of multiplication. Every integer factors into primes, and the factorization is unique up to order (the fundamental theorem of arithmetic). This uniqueness is not self-evident: proving it requires a detour through Bézout’s identity.
- There are infinitely many primes. Euclid’s proof is 2300 years old, but Euler strengthened it to the far more quantitative statement .
- The number of primes up to is asymptotic to (the prime number theorem). The intuition “an integer near is prime with probability about ” is, verbatim, a theorem.
- The prime number theorem itself needs complex analysis, but merely staring at the binomial coefficient yields upper and lower bounds of the correct order for (Chebyshev-type bounds). We prove those bounds completely here.
- We know the average shape of the distribution, yet almost nothing about the behaviour of individual primes. The twin prime conjecture and the Goldbach conjecture are both open, and sharpening the error term is precisely the Riemann hypothesis.
1. Motivation
Section titled “1. Motivation”Primes, learned in primary school as “numbers divisible only by and themselves”, are among the first concepts one meets in mathematics. Even so, a substantial fraction of the basic questions about them remain unanswered today. That gap is where number theory begins.
Historically, the first theorem about primes is Proposition 20 of Book IX of Euclid’s Elements: “prime numbers are more than any assigned multitude of prime numbers”. The word “infinite” was avoided; the claim was stated constructively, as the assertion that given any finite list of primes one can produce a prime outside it. Read today, that formulation has not aged.
The next large step was to ask not for the number of primes but for their density. Around the age of fifteen (1792–93) Gauss, poring over tables of primes, noticed that the count of primes below is well approximated by . At about the same time Legendre proposed the approximation . Both were conjectures, not proofs. Around 1850 Chebyshev established, by elementary arguments alone, that lies between constant multiples of — that is, he pinned down the correct order of magnitude. In his 1859 memoir Riemann gave a framework expressing in terms of the zeros of the zeta function , and Hadamard and de la Vallée Poussin, completing that framework analytically, proved the prime number theorem independently in 1896. About a century had passed since Gauss’s observation.
This article follows that thread in the following order. First we set up the definition of a prime together with the most basic tools of number theory, the division algorithm and Bézout’s identity. Next we prove Euclid’s theorem and the fundamental theorem of arithmetic. We then prove two quantitative results measuring how numerous the primes are (Euler’s divergence theorem and Chebyshev’s bounds), state the prime number theorem, and finally survey the open problems. If the proof techniques themselves are unfamiliar, read Techniques of Proof first.
2. Preliminaries: divisibility and greatest common divisors
Section titled “2. Preliminaries: divisibility and greatest common divisors”Throughout, unless stated otherwise, all letters denote integers. We set , excluding .
Definition 2.1(Divisibility and greatest common divisor)
For integers , we say that divides , written , if there is an integer with . When does not divide we write .
If and are not both , the greatest common divisor is defined to be the largest of the common divisors of and . Every common divisor is at most , so the maximum exists. When we call and coprime.
Definition 2.2(Primes and composites)
An integer is prime if its only positive divisors are and . An integer greater than that is not prime is called composite. The number is neither prime nor composite.
Excluding from the primes is not a convention of convenience but a necessity. If were prime we would have , and the uniqueness of prime factorization proved below would collapse.
Lemma 2.3(Division algorithm)
Let be an integer and a positive integer. Then there is exactly one pair of integers with
Proof(Lemma 2.3)
Existence. Consider the set . Taking gives (we used ), so . Being a nonempty set of nonnegative integers, has a least element by well-ordering(Axiom 3.1)[Techniques of Proof]. If , then would also lie in with , contradicting minimality of . Hence .
Uniqueness. Suppose with . Then . From we get , so , that is ; hence and therefore .
Lemma 2.4(Bézout's identity)
Let be integers, not both , and put . Then there exist integers with . Moreover is the least positive integer belonging to the set .
Proof(Lemma 2.4)
Since lies in , the set of positive integers in is nonempty, and by well-ordering it has a least element .
We first show . By Lemma 2.3 we may write with . Then
If this would contradict the minimality of , so , that is . The same argument gives , so is a common divisor of and .
Next, let be any common divisor of and . Then , so . Hence is the largest common divisor, and by the definition in Definition 2.1 we get .
3. The infinitude of primes
Section titled “3. The infinitude of primes”Lemma 3.1(The least divisor is prime)
Every integer has at least one prime factor. More precisely, the least of the positive divisors of exceeding is prime.
Proof(Lemma 3.1)
The set of positive divisors of exceeding contains itself, so it is nonempty; by well-ordering it has a least element . If were not prime, there would be a divisor of with . From and we get , so is a divisor of exceeding with , contradicting the minimality of . Hence is prime.
Theorem 3.2(Euclid's theorem)
There are infinitely many primes. That is, for any finitely many primes there exists a prime different from all of them.
Proof(Theorem 3.2)
Let be any finite collection of primes and set
Since each we have . By Lemma 3.1, has a prime factor .
If for some , then and , whence divides the difference, . But primes are at least , so is impossible. Hence is a prime distinct from every .
Assuming there were only finitely many primes , the prime just constructed would fail to be on the list — a contradiction. Therefore there are infinitely many primes.
Example 3.3( need not be prime)
This proof is often misreported as saying that adding to the product of the first primes produces a new prime. What it actually produces is a number possessing a new prime factor; there is no guarantee that the number itself is prime. The first few cases are indeed prime:
are all prime. At the next stage this breaks down:
Indeed . So is composite, yet neither of its prime factors and belongs to . That, and nothing more, is what the proof claims.
4. The fundamental theorem of arithmetic
Section titled “4. The fundamental theorem of arithmetic”We now know there are infinitely many primes. Next we examine how the primes assemble the integers.
Lemma 4.1(Euclid's lemma)
Let be prime and integers. If , then or .
Proof(Lemma 4.1)
If the conclusion holds, so assume and let us show .
Since is a positive divisor of , by Definition 2.2 it equals or . If then , contrary to assumption, so . By Lemma 2.4 there are integers with
Multiplying both sides by gives
The first term on the right is a multiple of , and so is the second by the hypothesis . Hence .
The statement of the lemma is special to primes: it fails for composite . Taking , , we have but and .
Theorem 4.2(Fundamental theorem of arithmetic)
Every integer can be written as a product of primes, and the representation is unique up to the order of the factors. That is, if
with prime, and , then and for every .
Proof(Theorem 4.2)
Existence. We argue by strong induction on (complete induction(Theorem 4.3)[Techniques of Proof]). For , which is prime, we have a product of one factor. Let and assume the claim for all integers from to . If is prime it is its own representation. If is composite we may write with and . By the inductive hypothesis and are each products of primes, and concatenating these gives a representation of as a product of primes.
Uniqueness. We induct on , taking as the statement indexed by that the number is expressible as a product of primes.
Case . Here with prime. If then and , contradicting the primality of (Definition 2.2). Hence and .
Let and assume uniqueness for products of primes. Since , applying Lemma 4.1 repeatedly times yields for some . The positive divisors of are and only, and , so . Running the same argument in the other direction gives for some . Therefore
and hence (this is where we use that the factors are listed in increasing order). Dividing both sides by gives
an identity whose left side is a product of primes. By the inductive hypothesis and for , which is the assertion.
Collecting equal primes, every can be written uniquely as
with distinct primes and positive integers . For a prime we write for the largest with , and call it the -adic valuation.
Example 4.3(Irrationality of )
Here is a typical use of unique factorization. If were rational we could write with , so that . Apply to both sides. Since and , we get
whose left side is even and right side odd — a contradiction. What licenses the claim that the two sides have the same is precisely the uniqueness of factorization, Theorem 4.2. Without uniqueness the argument does not get off the ground. The classical proof using fractions in lowest terms is in Theorem 7.5[Techniques of Proof].
Remark 4.4(Unique factorization is not automatic)
Uniqueness looks obvious only because we are used to . In the ring we have
and none of factors further in this ring (consider the norm : we have , , , and no element has or ). So the factorization is genuinely two-fold (this example is treated in more detail in Example 3.1[フェルマーの最終定理]). What makes uniqueness work in is Lemma 2.4, hence the division algorithm — by no means a general phenomenon. Repairing this failure is the starting point of ideal theory, and it connects directly to the history of Fermat’s Last Theorem.
flowchart TD A["Division algorithm"] --> B["Bézout's identity"] B --> C["Euclid's lemma"] C --> D["Fundamental theorem of arithmetic (unique factorization)"] D --> E["Euler product"] E --> F["Divergence of Σ 1/p"] D --> G["Prime factorization of binomial coefficients"] G --> H["Chebyshev-type bounds"] E --> I["Prime number theorem"] H --> I I --> J["Riemann hypothesis and the error term"]
5. How numerous are the primes?
Section titled “5. How numerous are the primes?”Definition 5.1(The prime counting function and asymptotic equivalence)
For a real number , write for the number of primes not exceeding ; that is, . For instance (namely ) and .
For positive functions we write (as ) when , and say that and are asymptotically equivalent.
Theorem 5.2(Euler: divergence of the sum of reciprocals of primes)
For every real number ,
where the sum runs over all primes . In particular , and there are infinitely many primes.
Proof(Theorem 5.2)
Step 1: a lower bound for the harmonic sum. For we have , so . Summing over gives
(we used ).
Step 2: the Euler product inequality from unique factorization. Fix . For each prime we have , so the geometric series
converges. There are only finitely many primes below , so we may multiply these series together and expand term by term. Each term of the expansion has the form with distinct primes . By Theorem 4.2 such tuples of exponents correspond bijectively to the positive integers all of whose prime factors are . Hence
If then every prime factor of is at most , hence at most , so ; all terms are positive, so combining with Step 1,
Step 3: take logarithms and convert to a sum. Taking logarithms of both sides,
Now for we have , whence
(using for ). Setting ,
Bounding the sum over primes by the sum over all integers,
(a telescoping sum). Therefore
and rearranging gives the assertion. As the right-hand side diverges to , so . If there were only finitely many primes the sum would be finite; hence there are infinitely many.
This theorem carries more information than Theorem 3.2. Since the sum of reciprocals of the squares converges, (the Basel problem(Example 3.5)[リーマン予想とは何か]), it tells us that the primes are distributed more densely than the squares. At the same time the growth is extraordinarily slow, so it also shows that the primes are quite thin.
Proposition 5.3(Chebyshev-type bounds)
Thus differs from by at most a constant factor.
Proof(Proposition 5.3)
We prove the lower bound here and defer the upper bound to the Appendix.
Let be a positive integer and consider the central binomial coefficient .
Step 1: is large. By the binomial theorem . The left side is a sum of terms, of which is the largest ( attains its maximum at ). Hence
Step 2: the prime factors of are small, and so are their exponents. We have . The exponent of a prime in is
(among there are exactly multiples of , and a number whose -exponent is exactly gets counted times, for ). Therefore
Writing a real number as with , we get , so each term of the sum is or . Moreover, when both floors vanish and the term disappears. Hence is at most the number of with , and consequently
Also, a prime dividing divides , so . By Theorem 4.2 we may factor , whence
Step 3: compare the two. Steps 1 and 2 give . Taking logarithms,
that is
As the right-hand side converges to .
Finally we pass to real . For put , so that . Since is nondecreasing we have , and
(using and ). As the right side tends to , giving the assertion about the .
6. The prime number theorem
Section titled “6. The prime number theorem”Definition 6.1(Logarithmic integral)
For the logarithmic integral is defined by
(the principal value at ). Repeated integration by parts yields the asymptotic expansion
and in particular .
Theorem 6.2(Prime number theorem)
that is, . Equivalently, .
Remark 6.3(On the proof)
A proof of the prime number theorem lies beyond the scope of this article. The heart of the first proof, given in 1896 by Hadamard and de la Vallée Poussin, is to show that the Riemann zeta function
has no zero on the line . The Euler product (the second equality above, Theorem 3.1[リーマン予想とは何か]) follows by exactly the argument of Step 2 of Theorem 5.2, that is, from Theorem 4.2. The prime number theorem and the statement "" are in fact known to be equivalent. In modern terms there is a short proof due to Newman, whose three-page exposition by Zagier is very readable. In 1949 Erdős and Selberg gave an elementary proof avoiding complex analysis (elementary does not mean easy). The zeta-function side of the story is treated in What Is the Riemann Hypothesis.
The content of the prime number theorem is easiest to grasp through the probabilistic reading “an integer near is prime with probability about ”. Indeed is nothing but the integral of this density. Near we have , so roughly out of every integers there are prime.
Let us check this numerically.
| 168 | 144.8 | 1.161 | 178 | 10 | |
| 1 229 | 1 085.7 | 1.132 | 1 246 | 17 | |
| 9 592 | 8 685.9 | 1.104 | 9 630 | 38 | |
| 78 498 | 72 382.4 | 1.084 | 78 628 | 130 | |
| 664 579 | 620 420.7 | 1.071 | 664 918 | 339 | |
| 5 761 455 | 5 428 681.0 | 1.061 | 5 762 209 | 754 | |
| 50 847 534 | 48 254 942.4 | 1.054 | 50 849 235 | 1 701 | |
| 455 052 511 | 434 294 481.9 | 1.048 | 455 055 615 | 3 104 |
The fourth column does tend to , but even at it is still off by . This is no accident. The asymptotic expansion in Definition 6.1 gives , so the error in the ratio decreases at a rate of order . At this is , in good agreement with the observed . The sixth column, by contrast, shows a difference from that is smaller than itself by many orders of magnitude, which shows that is a far better approximation.
Example 6.4(Counting with the sieve of Eratosthenes)
The values in the table can be verified directly. The following code uses only the standard library.
def sieve(n): is_prime = bytearray([1]) * (n + 1) is_prime[0] = is_prime[1] = 0 p = 2 while p * p <= n: if is_prime[p]: # multiples of p below p*p are already struck out by a smaller prime factor is_prime[p * p :: p] = bytearray(len(range(p * p, n + 1, p))) p += 1 return is_prime
import math
s = sieve(10**6)pi = sum(s)print(pi) # 78498print(10**6 / math.log(10**6)) # 72382.41365054197print(pi / (10**6 / math.log(10**6))) # 1.0844...Starting the inner elimination at is legitimate because any multiple of with , hence below , has already been struck out through a prime factor of (Lemma 3.1). Stopping the outer loop at is legitimate because every composite has a prime factor at most (if with then , and the least prime factor of is at most ).
Example 6.5(Arbitrarily long gaps between primes)
That primes appear on average with density does not mean they are spread out evenly. For consider the consecutive integers
For we have and , so ; moreover , so is composite. Hence there exist consecutive composite integers. Since is arbitrary, the gaps between primes become arbitrarily large. For instance with the nine numbers are consecutive composites (in reality primes occur in much shorter intervals near this point, but for an existence proof this suffices).
7. Open problems
Section titled “7. Open problems”The prime number theorem completely determines the distribution of primes on average. About the behaviour of individual primes, however, astonishingly little is known.
7.1. The twin prime conjecture
Section titled “7.1. The twin prime conjecture”A pair of primes differing by is called a pair of twin primes: .
Twin prime conjecture: there are infinitely many twin primes.
The heuristic count suggested by the prime number theorem (the Hardy–Littlewood conjecture) predicts that the number of twin prime pairs up to is , where is the twin prime constant; it matches numerical experiment well. Yet even infinitude is open.
Some things are known. In 1919 Brun proved that the sum of the reciprocals of the twin primes,
converges (its value, Brun’s constant, is estimated to be ). This contrasts with in Theorem 5.2 and means that twin primes are far rarer than primes in general. Note that convergence does not imply that there are only finitely many twin primes.
In 2013 Yitang Zhang proved that there are infinitely many pairs of primes differing by at most — the first finite bound for which infinitude could be established. Immediately afterwards Maynard and Tao independently gave different methods, and through the collaborative Polymath project the bound has been pushed down to . Reaching is out of range for the present methods.
7.2. The Goldbach conjecture
Section titled “7.2. The Goldbach conjecture”The origin is a letter written by Goldbach to Euler in 1742.
(Strong) Goldbach conjecture: every even integer is a sum of two primes.
As in , , , , the number of representations grows with the number. Verification by computer has reached , but there is no proof.
Weak Goldbach conjecture: every odd integer is a sum of three primes.
The weak conjecture follows from the strong one (for odd , is an even number ). Vinogradov proved the weak conjecture for all sufficiently large odd numbers in 1937, and in 2013 Helfgott handled the remaining finitely many cases and announced a complete proof (formal publication has been a long process). As for the strong conjecture, Chen Jingrun showed in 1973 that every sufficiently large even number is the sum of a prime and a number that is either prime or a product of two primes.
7.3. The error term and the Riemann hypothesis
Section titled “7.3. The error term and the Riemann hypothesis”The prime number theorem says , but the size of the error is not known in any definitive form. In 1901 von Koch showed that the Riemann hypothesis is equivalent to
(Theorem 6.3[リーマン予想とは何か]). In the table above one can see that is consistently positive and stays of size about (at we have and the difference is ).
“Consistently positive” does not last forever, however. In 1914 Littlewood proved that changes sign infinitely often. The location of the first sign change is still not determined; only upper bounds (the estimates known as Skewes numbers) are available. The lesson of number theory here is that what the computations reveal is not the whole story.
8. Exercises
Section titled “8. Exercises”Exercise 8.1Easy
Prove that there are infinitely many primes of the form .
Solution
Suppose there were only finitely many primes of the form , say , and put
Then and .
Since is odd, all its prime factors are odd primes, hence of the form or . If every prime factor were of the form , then since the product would also be of the form , contradicting . Hence has a prime factor of the form (existence of a prime factor is Lemma 3.1).
By assumption for some . Then and , so , contradicting . Therefore there are infinitely many primes of the form .
Infinitude also holds for primes of the form , but this elementary argument does not carry over as it stands; one needs the condition for to be a quadratic residue mod . See Congruences and Fermat’s Little Theorem for details.
Exercise 8.2Standard
Let be the primes in increasing order. Show that .
Solution
It suffices to show that for every there is an with .
Put . By the same argument as in Example 6.5, the numbers are all composite. Since , the set of primes not exceeding is nonempty and finite; let be its largest element, so .
On the other hand is the least prime exceeding , and since are all composite we get . Hence
As was arbitrary, .
Theorem 6.2 shows that the average gap is about , but as this exercise shows, individual gaps become arbitrarily large.
Exercise 8.3Standard
Let be a positive integer. Show that if is prime then is prime, and show by an explicit example that the converse fails.
Solution
We prove the contrapositive. Suppose is not prime. If then is not prime. If is composite, write with and . Substituting into the identity
shows that divides . From we get , and from we get . So has a divisor other than and itself, and by Definition 2.2 it is not prime.
The converse fails. Here is prime, yet
(indeed ). Primes of the form are called Mersenne primes; whether infinitely many exist is open.
Exercise 8.4Hard
Let be an integer with . Show that
(an argument that yields a quantitative form of the infinitude of primes using unique factorization alone, without binomial coefficients).
Solution
Write each integer with in the form , where is a squarefree positive integer and is a positive integer. Indeed, by Theorem 4.2 we may write uniquely, so setting
each exponent in is or , so is squarefree, and .
Let us count the possibilities for . The prime factors of are prime factors of , hence at most , and each prime either occurs or does not, so there are at most candidates for . Next count . From we get , so there are at most candidates for .
The assignment of to the pair is injective (since is recovered as ), so
Dividing by gives , and taking logarithms,
This bound gives and so reproves the infinitude of primes, but compared with the true size it is overwhelmingly weak. Compare it with Proposition 5.3.
References
Section titled “References”- G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 6th ed., Oxford University Press, 2008 — Chapter 1 (divisibility and primes), Chapter 2 (the distribution of primes), Chapter 22 (the distribution of primes, continued).
- Takagi Teiji, Shotō Seisūron Kōgi (Lectures on Elementary Number Theory), 2nd ed., Kyoritsu Shuppan, 1971 (in Japanese) — Chapter 1 (division of integers, greatest common divisors, prime factorization).
- T. M. Apostol, Introduction to Analytic Number Theory, Springer, 1976 — Chapter 3 (averages), Chapter 4 (Chebyshev’s functions and the prime number theorem).
- D. Zagier, “Newman’s short proof of the prime number theorem”, American Mathematical Monthly 104 (1997), 705–708 — the shortest modern presentation of the analytic proof of the prime number theorem.
- Y. Zhang, “Bounded gaps between primes”, Annals of Mathematics 179 (2014), 1121–1174.
- J. Maynard, “Small gaps between primes”, Annals of Mathematics 181 (2015), 383–413.
Appendix: proof of the Chebyshev upper bound
Section titled “Appendix: proof of the Chebyshev upper bound”Goal. We prove the second half of Proposition 5.3, namely . The key is to estimate not the number of primes but the sum of their logarithms,
(Chebyshev’s first function). Since , what follows is the same as the assertion that the product of the primes up to does not exceed .
Step 1: for . We argue by strong induction on . For the left side is the empty product and the right side is , so the claim holds. For the left side is and the right side is .
Let and assume the claim for all positive integers below . If is even, then since it is not prime, so .
If is odd, write with . Consider a prime with . Such a appears as a factor of , while means it divides neither nor . Hence
is divisible by (by Lemma 4.1, a prime dividing the numerator but not the denominator survives into the quotient). Combining this over distinct primes (again by Theorem 4.2),
Moreover , and these are two of the terms of , so
Applying the inductive hypothesis to gives , whence
which completes the induction. For real we get .
Step 2: from to . Let . For each prime with we have , so
Since is a trivial bound (the primes up to form part of the positive integers up to ),
Step 3: choosing . Take (for large enough, ). Then , so
As we have , so the right side converges to . Hence .
Summary. The lower bound and the upper bound of Proposition 5.3 do indeed straddle the value asserted by Theorem 6.2. Chebyshev refined arguments of this kind as far as for sufficiently large , but that the limit is exactly cannot be obtained from this direction. That is where the zeta function becomes necessary — the heart of the story of the prime number theorem.
Report an error in this article ・Operated by: Mugen Giken LLC ・Pricing ・Terms ・Legal notice
© 2026 夢現技研合同会社 ・Feeding the text to an LLM is welcome. Code samples are MIT licensed.