Skip to content

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 LogicIntroduction to Group Theory: The Axioms, and a Language for Computing with Symmetry

Raw
  • 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 p1/p=\sum_p 1/p = \infty.
  • The number π(x)\pi(x) of primes up to xx is asymptotic to x/logxx/\log x (the prime number theorem). The intuition “an integer near nn is prime with probability about 1/logn1/\log n” is, verbatim, a theorem.
  • The prime number theorem itself needs complex analysis, but merely staring at the binomial coefficient (2nn)\binom{2n}{n} yields upper and lower bounds of the correct order for π(x)\pi(x) (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.

Primes, learned in primary school as “numbers divisible only by 11 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 xx is well approximated by 2xdt/logt\int_2^x dt/\log t. At about the same time Legendre proposed the approximation x/(logx1.08366)x/(\log x - 1.08366). Both were conjectures, not proofs. Around 1850 Chebyshev established, by elementary arguments alone, that π(x)\pi(x) lies between constant multiples of x/logxx/\log x — that is, he pinned down the correct order of magnitude. In his 1859 memoir Riemann gave a framework expressing π(x)\pi(x) in terms of the zeros of the zeta function ζ(s)\zeta(s), 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 N={1,2,}\mathbb{N} = \{1, 2, \ldots\}, excluding 00.

Definition 2.1Divisibility and greatest common divisor

For integers a,ba, b, we say that aa divides bb, written aba \mid b, if there is an integer cc with b=acb = ac. When aa does not divide bb we write aba \nmid b.

If aa and bb are not both 00, the greatest common divisor gcd(a,b)\gcd(a,b) is defined to be the largest of the common divisors of aa and bb. Every common divisor is at most min(a,b)\min(|a|,|b|), so the maximum exists. When gcd(a,b)=1\gcd(a,b) = 1 we call aa and bb coprime.

Definition 2.2Primes and composites

An integer p>1p > 1 is prime if its only positive divisors are 11 and pp. An integer greater than 11 that is not prime is called composite. The number 11 is neither prime nor composite.

Excluding 11 from the primes is not a convention of convenience but a necessity. If 11 were prime we would have 6=23=123=11236 = 2\cdot 3 = 1 \cdot 2\cdot 3 = 1\cdot 1\cdot 2\cdot 3, and the uniqueness of prime factorization proved below would collapse.

Lemma 2.3Division algorithm

Let aa be an integer and bb a positive integer. Then there is exactly one pair (q,r)(q, r) of integers with

a=bq+r,0r<b.a = bq + r, \qquad 0 \le r < b.
Proof(Lemma 2.3)

Existence. Consider the set S={abq:qZ, abq0}S = \{a - bq : q \in \mathbb{Z},\ a - bq \ge 0\}. Taking q=aq = -|a| gives abq=a+baa+a0a - bq = a + b|a| \ge a + |a| \ge 0 (we used b1b \ge 1), so SS \ne \varnothing. Being a nonempty set of nonnegative integers, SS has a least element r=abqr = a - bq by well-ordering(Axiom 3.1)[Techniques of Proof]. If rbr \ge b, then rb=ab(q+1)0r - b = a - b(q+1) \ge 0 would also lie in SS with rb<rr - b < r, contradicting minimality of rr. Hence 0r<b0 \le r < b.

Uniqueness. Suppose bq+r=bq+rbq + r = bq' + r' with 0r,r<b0 \le r, r' < b. Then b(qq)=rrb(q - q') = r' - r. From 0r,r<b0 \le r, r' < b we get rr<b|r' - r| < b, so bqq<bb|q - q'| < b, that is qq<1|q - q'| < 1; hence q=qq = q' and therefore r=rr = r'.

Lemma 2.4Bézout's identity

Let a,ba, b be integers, not both 00, and put d=gcd(a,b)d = \gcd(a, b). Then there exist integers x0,y0x_0, y_0 with d=ax0+by0d = ax_0 + by_0. Moreover dd is the least positive integer belonging to the set I={ax+by:x,yZ}I = \{ax + by : x, y \in \mathbb{Z}\}.

Proof(Lemma 2.4)

Since a2+b2>0a^2 + b^2 > 0 lies in II, the set of positive integers in II is nonempty, and by well-ordering it has a least element d0=ax0+by0d_0 = ax_0 + by_0.

We first show d0ad_0 \mid a. By Lemma 2.3 we may write a=d0q+ra = d_0 q + r with 0r<d00 \le r < d_0. Then

r=ad0q=a(ax0+by0)q=a(1qx0)+b(qy0)Ir = a - d_0 q = a - (ax_0 + by_0)q = a(1 - qx_0) + b(-qy_0) \in I

If 0<r<d00 < r < d_0 this would contradict the minimality of d0d_0, so r=0r = 0, that is d0ad_0 \mid a. The same argument gives d0bd_0 \mid b, so d0d_0 is a common divisor of aa and bb.

Next, let cc be any common divisor of aa and bb. Then cax0+by0=d0c \mid ax_0 + by_0 = d_0, so ccd0c \le |c| \le d_0. Hence d0d_0 is the largest common divisor, and by the definition in Definition 2.1 we get d0=gcd(a,b)=dd_0 = \gcd(a,b) = d.

Lemma 3.1The least divisor is prime

Every integer n>1n > 1 has at least one prime factor. More precisely, the least of the positive divisors of nn exceeding 11 is prime.

Proof(Lemma 3.1)

The set of positive divisors of n>1n > 1 exceeding 11 contains nn itself, so it is nonempty; by well-ordering it has a least element pp. If pp were not prime, there would be a divisor ee of pp with 1<e<p1 < e < p. From epe \mid p and pnp \mid n we get ene \mid n, so ee is a divisor of nn exceeding 11 with e<pe < p, contradicting the minimality of pp. Hence pp is prime.

Theorem 3.2Euclid's theorem

There are infinitely many primes. That is, for any finitely many primes p1,,pkp_1, \ldots, p_k there exists a prime different from all of them.

Proof(Theorem 3.2)

Let p1,,pkp_1, \ldots, p_k be any finite collection of primes and set

N=p1p2pk+1N = p_1 p_2 \cdots p_k + 1

Since each pi2p_i \ge 2 we have N3>1N \ge 3 > 1. By Lemma 3.1, NN has a prime factor qq.

If q=piq = p_i for some ii, then qp1pkq \mid p_1\cdots p_k and qNq \mid N, whence qq divides the difference, qNp1pk=1q \mid N - p_1\cdots p_k = 1. But primes are at least 22, so q1q \mid 1 is impossible. Hence qq is a prime distinct from every p1,,pkp_1, \ldots, p_k.

Assuming there were only finitely many primes p1,,pkp_1, \ldots, p_k, the prime qq just constructed would fail to be on the list — a contradiction. Therefore there are infinitely many primes.

Example 3.3p1pk+1p_1\cdots p_k + 1 need not be prime

This proof is often misreported as saying that adding 11 to the product of the first kk 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:

2+1=3,23+1=7,235+1=31,2357+1=211,235711+1=23112+1 = 3,\quad 2\cdot3+1 = 7,\quad 2\cdot3\cdot5+1 = 31,\quad 2\cdot3\cdot5\cdot7+1 = 211,\quad 2\cdot3\cdot5\cdot7\cdot11+1 = 2311

are all prime. At the next stage this breaks down:

23571113+1=30030+1=30031=59×509.2\cdot3\cdot5\cdot7\cdot11\cdot13 + 1 = 30030 + 1 = 30031 = 59 \times 509.

Indeed 59×509=59×500+59×9=29500+531=3003159 \times 509 = 59\times 500 + 59\times 9 = 29500 + 531 = 30031. So 3003130031 is composite, yet neither of its prime factors 5959 and 509509 belongs to {2,3,5,7,11,13}\{2,3,5,7,11,13\}. That, and nothing more, is what the proof claims.

We now know there are infinitely many primes. Next we examine how the primes assemble the integers.

Lemma 4.1Euclid's lemma

Let pp be prime and a,ba, b integers. If pabp \mid ab, then pap \mid a or pbp \mid b.

Proof(Lemma 4.1)

If pap \mid a the conclusion holds, so assume pap \nmid a and let us show pbp \mid b.

Since gcd(p,a)\gcd(p, a) is a positive divisor of pp, by Definition 2.2 it equals 11 or pp. If gcd(p,a)=p\gcd(p,a) = p then pap \mid a, contrary to assumption, so gcd(p,a)=1\gcd(p, a) = 1. By Lemma 2.4 there are integers x,yx, y with

1=px+ay1 = px + ay

Multiplying both sides by bb gives

b=pbx+(ab)yb = pbx + (ab)y

The first term on the right is a multiple of pp, and so is the second by the hypothesis pabp \mid ab. Hence pbp \mid b.

The statement of the lemma is special to primes: it fails for composite pp. Taking p=6p = 6, a=2a = 2, b=3b = 3 we have 66=ab6 \mid 6 = ab but 626 \nmid 2 and 636 \nmid 3.

Theorem 4.2Fundamental theorem of arithmetic

Every integer n>1n > 1 can be written as a product of primes, and the representation is unique up to the order of the factors. That is, if

n=p1p2pr=q1q2qsn = p_1 p_2 \cdots p_r = q_1 q_2 \cdots q_s

with pi,qjp_i, q_j prime, p1prp_1 \le \cdots \le p_r and q1qsq_1 \le \cdots \le q_s, then r=sr = s and pi=qip_i = q_i for every ii.

Proof(Theorem 4.2)

Existence. We argue by strong induction on nn (complete induction(Theorem 4.3)[Techniques of Proof]). For n=2n = 2, which is prime, we have a product of one factor. Let n>2n > 2 and assume the claim for all integers from 22 to n1n-1. If nn is prime it is its own representation. If nn is composite we may write n=abn = ab with 1<a<n1 < a < n and 1<b<n1 < b < n. By the inductive hypothesis aa and bb are each products of primes, and concatenating these gives a representation of nn as a product of primes.

Uniqueness. We induct on rr, taking as the statement indexed by rr that the number is expressible as a product of rr primes.

Case r=1r = 1. Here p1=q1qsp_1 = q_1\cdots q_s with p1p_1 prime. If s2s \ge 2 then q1p1q_1 \mid p_1 and 1<q1<q1q2qs=p11 < q_1 < q_1 q_2 \cdots q_s = p_1, contradicting the primality of p1p_1 (Definition 2.2). Hence s=1s = 1 and p1=q1p_1 = q_1.

Let r2r \ge 2 and assume uniqueness for products of r1r - 1 primes. Since p1q1q2qsp_1 \mid q_1 q_2\cdots q_s, applying Lemma 4.1 repeatedly s1s-1 times yields p1qjp_1 \mid q_j for some jj. The positive divisors of qjq_j are 11 and qjq_j only, and p1>1p_1 > 1, so p1=qjp_1 = q_j. Running the same argument in the other direction gives q1=piq_1 = p_i for some ii. Therefore

p1pi=q1qj=p1p_1 \le p_i = q_1 \le q_j = p_1

and hence p1=q1p_1 = q_1 (this is where we use that the factors are listed in increasing order). Dividing both sides by p1p_1 gives

p2pr=q2qsp_2 \cdots p_r = q_2 \cdots q_s

an identity whose left side is a product of r1r-1 primes. By the inductive hypothesis r1=s1r - 1 = s - 1 and pi=qip_i = q_i for i2i \ge 2, which is the assertion.

Collecting equal primes, every n>1n > 1 can be written uniquely as

n=p1e1p2e2pkekn = p_1^{e_1} p_2^{e_2}\cdots p_k^{e_k}

with distinct primes p1<<pkp_1 < \cdots < p_k and positive integers e1,,eke_1, \ldots, e_k. For a prime pp we write vp(n)v_p(n) for the largest ee with penp^{e} \mid n, and call it the pp-adic valuation.

Example 4.3Irrationality of 2\sqrt{2}

Here is a typical use of unique factorization. If 2\sqrt 2 were rational we could write 2=a/b\sqrt 2 = a/b with a,bNa, b \in \mathbb{N}, so that a2=2b2a^2 = 2b^2. Apply v2v_2 to both sides. Since v2(a2)=2v2(a)v_2(a^2) = 2v_2(a) and v2(2b2)=1+2v2(b)v_2(2b^2) = 1 + 2v_2(b), we get

2v2(a)=1+2v2(b)2v_2(a) = 1 + 2v_2(b)

whose left side is even and right side odd — a contradiction. What licenses the claim that the two sides have the same v2v_2 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.4Unique factorization is not automatic

Uniqueness looks obvious only because we are used to Z\mathbb{Z}. In the ring Z[5]={a+b5:a,bZ}\mathbb{Z}[\sqrt{-5}] = \{a + b\sqrt{-5} : a, b \in \mathbb{Z}\} we have

6=23=(1+5)(15)6 = 2\cdot 3 = (1 + \sqrt{-5})(1 - \sqrt{-5})

and none of 2,3,1±52, 3, 1\pm\sqrt{-5} factors further in this ring (consider the norm N(a+b5)=a2+5b2N(a+b\sqrt{-5}) = a^2 + 5b^2: we have N(2)=4N(2) = 4, N(3)=9N(3) = 9, N(1±5)=6N(1\pm\sqrt{-5}) = 6, and no element has N(x)=2N(x) = 2 or N(x)=3N(x) = 3). So the factorization is genuinely two-fold (this example is treated in more detail in Example 3.1[フェルマーの最終定理]). What makes uniqueness work in Z\mathbb{Z} 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"]
The logical skeleton of this article: from the division algorithm through unique factorization to the distribution of primes

Definition 5.1The prime counting function and asymptotic equivalence

For a real number xx, write π(x)\pi(x) for the number of primes not exceeding xx; that is, π(x)=#{p:p prime, px}\pi(x) = \#\{p : p \text{ prime},\ p \le x\}. For instance π(10)=4\pi(10) = 4 (namely 2,3,5,72,3,5,7) and π(100)=25\pi(100) = 25.

For positive functions f,gf, g we write f(x)g(x)f(x) \sim g(x) (as xx \to \infty) when limxf(x)/g(x)=1\lim_{x\to\infty} f(x)/g(x) = 1, and say that ff and gg are asymptotically equivalent.

Theorem 5.2Euler: divergence of the sum of reciprocals of primes

For every real number x2x \ge 2,

px1ploglogx12\sum_{p \le x} \frac{1}{p} \ge \log\log x - \frac{1}{2}

where the sum runs over all primes pxp \le x. In particular p1/p=\sum_{p} 1/p = \infty, and there are infinitely many primes.

Proof(Theorem 5.2)

Step 1: a lower bound for the harmonic sum. For ntn+1n \le t \le n+1 we have 1/n1/t1/n \ge 1/t, so 1nnn+1dtt\frac1n \ge \int_n^{n+1}\frac{dt}{t}. Summing over n=1,,xn = 1, \ldots, \lfloor x\rfloor gives

nx1n  1x+1dtt  1xdtt=logx\sum_{n \le x}\frac1n \ \ge\ \int_1^{\lfloor x\rfloor + 1}\frac{dt}{t} \ \ge\ \int_1^{x}\frac{dt}{t} = \log x

(we used x+1>x\lfloor x\rfloor + 1 > x).

Step 2: the Euler product inequality from unique factorization. Fix x2x \ge 2. For each prime pxp \le x we have 0<1/p1/2<10 < 1/p \le 1/2 < 1, so the geometric series

(11p)1=k=01pk\left(1 - \frac1p\right)^{-1} = \sum_{k=0}^{\infty} \frac{1}{p^{k}}

converges. There are only finitely many primes below xx, so we may multiply these series together and expand term by term. Each term of the expansion has the form 1/(p1k1pmkm)1/(p_1^{k_1}\cdots p_m^{k_m}) with p1,,pmp_1, \ldots, p_m distinct primes x\le x. By Theorem 4.2 such tuples of exponents correspond bijectively to the positive integers nn all of whose prime factors are x\le x. Hence

px(11p)1=nA(x)1n,A(x)={nN:every prime factor of n isx}\prod_{p \le x}\left(1 - \frac1p\right)^{-1} = \sum_{n \in A(x)} \frac1n, \qquad A(x) = \{n \in \mathbb{N} : \text{every prime factor of } n \text{ is} \le x\}

If nxn \le x then every prime factor of nn is at most nn, hence at most xx, so {nN:nx}A(x)\{n \in \mathbb{N} : n \le x\} \subset A(x); all terms are positive, so combining with Step 1,

px(11p)1  nx1n  logx\prod_{p \le x}\left(1 - \frac1p\right)^{-1} \ \ge\ \sum_{n\le x}\frac1n \ \ge\ \log x

Step 3: take logarithms and convert to a sum. Taking logarithms of both sides,

px(log(11p))  loglogx\sum_{p \le x} \left(-\log\left(1 - \frac1p\right)\right) \ \ge\ \log\log x

Now for 0<t<10 < t < 1 we have log(1t)=k1tk/k-\log(1-t) = \sum_{k\ge1} t^k/k, whence

log(1t)t+12k2tk=t+t22(1t)-\log(1-t) \le t + \frac12\sum_{k \ge 2} t^{k} = t + \frac{t^2}{2(1-t)}

(using 1/k1/21/k \le 1/2 for k2k \ge 2). Setting t=1/pt = 1/p,

log(11p)1p+12p2pp1=1p+12p(p1)-\log\left(1 - \frac1p\right) \le \frac1p + \frac{1}{2p^2}\cdot\frac{p}{p-1} = \frac1p + \frac{1}{2p(p-1)}

Bounding the sum over primes by the sum over all integers,

p12p(p1)12m21m(m1)=12m2(1m11m)=12\sum_{p} \frac{1}{2p(p-1)} \le \frac12\sum_{m \ge 2}\frac{1}{m(m-1)} = \frac12\sum_{m\ge2}\left(\frac{1}{m-1} - \frac1m\right) = \frac12

(a telescoping sum). Therefore

loglogxpx(log(11p))px1p+12\log\log x \le \sum_{p\le x}\left(-\log\left(1-\frac1p\right)\right) \le \sum_{p \le x}\frac1p + \frac12

and rearranging gives the assertion. As xx \to \infty the right-hand side diverges to \infty, so p1/p=\sum_p 1/p = \infty. 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, 1/n2=π2/6\sum 1/n^2 = \pi^2/6 (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 px1/ploglogx\sum_{p\le x} 1/p \approx \log\log x is extraordinarily slow, so it also shows that the primes are quite thin.

Proposition 5.3Chebyshev-type bounds

lim infxπ(x)logxx  log2=0.6931,lim supxπ(x)logxx  log4=1.3862\liminf_{x\to\infty}\frac{\pi(x)\log x}{x} \ \ge\ \log 2 = 0.6931\ldots, \qquad \limsup_{x\to\infty}\frac{\pi(x)\log x}{x} \ \le\ \log 4 = 1.3862\ldots

Thus π(x)\pi(x) differs from x/logxx/\log x 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 nn be a positive integer and consider the central binomial coefficient C=(2nn)C = \binom{2n}{n}.

Step 1: CC is large. By the binomial theorem k=02n(2nk)=22n=4n\sum_{k=0}^{2n}\binom{2n}{k} = 2^{2n} = 4^n. The left side is a sum of 2n+12n+1 terms, of which (2nn)\binom{2n}{n} is the largest ((2nk)\binom{2n}{k} attains its maximum at k=nk = n). Hence

(2n+1)C  4n,that isC  4n2n+1.(2n+1)\,C \ \ge\ 4^n, \qquad \text{that is}\qquad C \ \ge\ \frac{4^n}{2n+1}.

Step 2: the prime factors of CC are small, and so are their exponents. We have C=(2n)!/(n!)2C = (2n)!/(n!)^2. The exponent of a prime pp in m!m! is

vp(m!)=i1mpiv_p(m!) = \sum_{i \ge 1}\left\lfloor \frac{m}{p^i}\right\rfloor

(among 1,,m1, \ldots, m there are exactly m/pi\lfloor m/p^i\rfloor multiples of pip^i, and a number whose pp-exponent is exactly ee gets counted ee times, for i=1,,ei = 1,\ldots,e). Therefore

vp(C)=i1(2npi2npi).v_p(C) = \sum_{i\ge1}\left(\left\lfloor\frac{2n}{p^i}\right\rfloor - 2\left\lfloor\frac{n}{p^i}\right\rfloor\right).

Writing a real number tt as t=t+θt = \lfloor t\rfloor + \theta with 0θ<10 \le \theta < 1, we get 2t2t=2θ{0,1}\lfloor 2t\rfloor - 2\lfloor t\rfloor = \lfloor 2\theta\rfloor \in \{0, 1\}, so each term of the sum is 00 or 11. Moreover, when pi>2np^i > 2n both floors vanish and the term disappears. Hence vp(C)v_p(C) is at most the number of ii with pi2np^i \le 2n, and consequently

pvp(C)2np^{v_p(C)} \le 2n

Also, a prime dividing CC divides (2n)!(2n)!, so p2np \le 2n. By Theorem 4.2 we may factor C=p2npvp(C)C = \prod_{p \le 2n} p^{v_p(C)}, whence

C=p2npvp(C)(2n)π(2n).C = \prod_{p\le 2n} p^{v_p(C)} \le (2n)^{\pi(2n)}.

Step 3: compare the two. Steps 1 and 2 give (2n)π(2n)4n/(2n+1)(2n)^{\pi(2n)} \ge 4^n/(2n+1). Taking logarithms,

π(2n)log(2n)  2nlog2log(2n+1),\pi(2n)\log(2n) \ \ge\ 2n\log 2 - \log(2n+1),

that is

π(2n)log(2n)2n  log2log(2n+1)2n.\frac{\pi(2n)\log(2n)}{2n} \ \ge\ \log 2 - \frac{\log(2n+1)}{2n}.

As nn \to \infty the right-hand side converges to log2\log 2.

Finally we pass to real xx \to \infty. For x4x \ge 4 put n=x/2n = \lfloor x/2\rfloor, so that 2nx<2n+22n \le x < 2n + 2. Since π\pi is nondecreasing we have π(x)π(2n)\pi(x) \ge \pi(2n), and

π(x)logxx  π(2n)log(2n)2n2nx  (log2log(2n+1)2n)x2x\frac{\pi(x)\log x}{x} \ \ge\ \frac{\pi(2n)\log (2n)}{2n}\cdot\frac{2n}{x} \ \ge\ \left(\log 2 - \frac{\log(2n+1)}{2n}\right)\cdot\frac{x-2}{x}

(using logxlog2n\log x \ge \log 2n and 2n>x22n > x - 2). As xx\to\infty the right side tends to log2\log 2, giving the assertion about the lim inf\liminf.

Definition 6.1Logarithmic integral

For x>1x > 1 the logarithmic integral is defined by

li(x)=limε0+(01εdtlogt+1+εxdtlogt)\mathrm{li}(x) = \lim_{\varepsilon \to 0+}\left(\int_0^{1-\varepsilon}\frac{dt}{\log t} + \int_{1+\varepsilon}^{x}\frac{dt}{\log t}\right)

(the principal value at t=1t = 1). Repeated integration by parts yields the asymptotic expansion

li(x)=xlogx+x(logx)2+2x(logx)3+\mathrm{li}(x) = \frac{x}{\log x} + \frac{x}{(\log x)^2} + \frac{2x}{(\log x)^3} + \cdots

and in particular li(x)x/logx\mathrm{li}(x) \sim x/\log x.

Theorem 6.2Prime number theorem

π(x)xlogx(x),\pi(x) \sim \frac{x}{\log x} \qquad (x \to \infty),

that is, limxπ(x)logxx=1\lim_{x\to\infty}\dfrac{\pi(x)\log x}{x} = 1. Equivalently, π(x)li(x)\pi(x)\sim \mathrm{li}(x).

Remark 6.3On 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

ζ(s)=n=11ns=p(11ps)1(Res>1)\zeta(s) = \sum_{n=1}^{\infty}\frac{1}{n^{s}} = \prod_{p}\left(1 - \frac{1}{p^{s}}\right)^{-1} \qquad (\operatorname{Re} s > 1)

has no zero on the line Res=1\operatorname{Re} s = 1. 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 "ζ(1+it)0\zeta(1+it)\ne0" 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 nn is prime with probability about 1/logn1/\log n”. Indeed 2xdt/logt\int_2^x dt/\log t is nothing but the integral of this density. Near x=1010x = 10^{10} we have 1/log(1010)1/23.04.3%1/\log(10^{10}) \approx 1/23.0 \approx 4.3\%, so roughly 44 out of every 100100 integers there are prime.

Let us check this numerically.

xxπ(x)\pi(x)x/logxx/\log xπ(x)/xlogx\pi(x)\big/\frac{x}{\log x}li(x)\mathrm{li}(x)li(x)π(x)\mathrm{li}(x)-\pi(x)
10310^{3}168144.81.16117810
10410^{4}1 2291 085.71.1321 24617
10510^{5}9 5928 685.91.1049 63038
10610^{6}78 49872 382.41.08478 628130
10710^{7}664 579620 420.71.071664 918339
10810^{8}5 761 4555 428 681.01.0615 762 209754
10910^{9}50 847 53448 254 942.41.05450 849 2351 701
101010^{10}455 052 511434 294 481.91.048455 055 6153 104

The fourth column does tend to 11, but even at x=1010x = 10^{10} it is still off by 4.8%4.8\%. This is no accident. The asymptotic expansion in Definition 6.1 gives li(x)x/logxx/(logx)2\mathrm{li}(x) - x/\log x \approx x/(\log x)^2, so the error in the ratio decreases at a rate of order 1/logx1/\log x. At x=1010x = 10^{10} this is 1/logx0.0431/\log x \approx 0.043, in good agreement with the observed 0.0480.048. The sixth column, by contrast, shows a difference from li(x)\mathrm{li}(x) that is smaller than π(x)\pi(x) itself by many orders of magnitude, which shows that li(x)\mathrm{li}(x) is a far better approximation.

1.201.151.101.051.0010³10⁴10⁵10⁶10⁷10⁸10⁹10¹⁰xπ(x) ÷ (x / log x)
The ratio of π(x) to x/log x. It approaches 1, but only at speed 1/log x (the horizontal axis is the common logarithm of x)

Example 6.4Counting π(106)\pi(10^6) 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) # 78498
print(10**6 / math.log(10**6)) # 72382.41365054197
print(pi / (10**6 / math.log(10**6))) # 1.0844...

Starting the inner elimination at p2p^2 is legitimate because any multiple kpkp of pp with k<pk < p, hence below p2p^2, has already been struck out through a prime factor of kk (Lemma 3.1). Stopping the outer loop at p2np^2 \le n is legitimate because every composite mnm \le n has a prime factor at most mn\sqrt m \le \sqrt n (if m=abm = ab with aba \le b then ama \le \sqrt m, and the least prime factor of aa is at most aa).

Example 6.5Arbitrarily long gaps between primes

That primes appear on average with density 1/logn1/\log n does not mean they are spread out evenly. For n2n \ge 2 consider the n1n-1 consecutive integers

n!+2, n!+3, , n!+nn! + 2,\ n! + 3,\ \ldots,\ n! + n

For 2kn2 \le k \le n we have kn!k \mid n! and kkk \mid k, so kn!+kk \mid n! + k; moreover 1<k<n!+k1 < k < n! + k, so n!+kn!+k is composite. Hence there exist n1n-1 consecutive composite integers. Since nn is arbitrary, the gaps between primes become arbitrarily large. For instance with n=10n = 10 the nine numbers 3628802,,36288103628802, \ldots, 3628810 are consecutive composites (in reality primes occur in much shorter intervals near this point, but for an existence proof this suffices).

The prime number theorem completely determines the distribution of primes on average. About the behaviour of individual primes, however, astonishingly little is known.

A pair of primes (p,p+2)(p, p+2) differing by 22 is called a pair of twin primes: (3,5),(5,7),(11,13),(17,19),(29,31),(3,5), (5,7), (11,13), (17,19), (29,31), \ldots.

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 xx is 2C22xdt/(logt)22C_2 \int_2^x dt/(\log t)^2, where C2=0.6601C_2 = 0.6601\ldots 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,

(13+15)+(15+17)+(111+113)+\left(\frac13+\frac15\right) + \left(\frac15+\frac17\right)+\left(\frac1{11}+\frac1{13}\right)+\cdots

converges (its value, Brun’s constant, is estimated to be 1.9021.902\ldots). This contrasts with p1/p=\sum_p 1/p = \infty 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 7×1077\times 10^{7} — 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 246246. Reaching 22 is out of range for the present methods.

The origin is a letter written by Goldbach to Euler in 1742.

(Strong) Goldbach conjecture: every even integer 4\ge 4 is a sum of two primes.

As in 4=2+24 = 2+2, 6=3+36 = 3+3, 8=3+58 = 3+5, 100=3+97=11+89=17+83=29+71=41+59=47+53100 = 3+97 = 11+89 = 17+83 = 29+71 = 41+59 = 47+53, the number of representations grows with the number. Verification by computer has reached 4×10184\times 10^{18}, but there is no proof.

Weak Goldbach conjecture: every odd integer 7\ge 7 is a sum of three primes.

The weak conjecture follows from the strong one (for odd n7n \ge 7, n3n - 3 is an even number 4\ge 4). 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 π(x)li(x)\pi(x) \sim \mathrm{li}(x), but the size of the error π(x)li(x)\pi(x) - \mathrm{li}(x) is not known in any definitive form. In 1901 von Koch showed that the Riemann hypothesis is equivalent to

π(x)=li(x)+O ⁣(xlogx)\pi(x) = \mathrm{li}(x) + O\!\left(\sqrt{x}\,\log x\right)

(Theorem 6.3[リーマン予想とは何か]). In the table above one can see that li(x)π(x)\mathrm{li}(x)-\pi(x) is consistently positive and stays of size about x\sqrt x (at x=1010x = 10^{10} we have x=105\sqrt x = 10^5 and the difference is 31043104).

“Consistently positive” does not last forever, however. In 1914 Littlewood proved that π(x)li(x)\pi(x) - \mathrm{li}(x) 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.

Exercise 8.1Easy

Prove that there are infinitely many primes of the form 4n+34n+3.

Solution

Suppose there were only finitely many primes of the form 4n+34n+3, say p1=3,p2,,pkp_1 = 3, p_2, \ldots, p_k, and put

N=4p1p2pk1N = 4p_1p_2\cdots p_k - 1

Then N431=11>1N \ge 4\cdot3 - 1 = 11 > 1 and N13(mod4)N \equiv -1 \equiv 3 \pmod 4.

Since NN is odd, all its prime factors are odd primes, hence of the form 4n+14n+1 or 4n+34n+3. If every prime factor were of the form 4n+14n+1, then since (4a+1)(4b+1)=4(4ab+a+b)+1(4a+1)(4b+1) = 4(4ab+a+b)+1 the product would also be of the form 4n+14n+1, contradicting N3(mod4)N \equiv 3 \pmod 4. Hence NN has a prime factor qq of the form 4n+34n+3 (existence of a prime factor is Lemma 3.1).

By assumption q=piq = p_i for some ii. Then q4p1pkq \mid 4p_1\cdots p_k and qNq \mid N, so q4p1pkN=1q \mid 4p_1\cdots p_k - N = 1, contradicting q3q \ge 3. Therefore there are infinitely many primes of the form 4n+34n+3.

Infinitude also holds for primes of the form 4n+14n+1, but this elementary argument does not carry over as it stands; one needs the condition for 1-1 to be a quadratic residue mod pp. See Congruences and Fermat’s Little Theorem for details.

Exercise 8.2Standard

Let p1=2<p2=3<p3=5<p_1 = 2 < p_2 = 3 < p_3 = 5 < \cdots be the primes in increasing order. Show that lim supn(pn+1pn)=\limsup_{n\to\infty}(p_{n+1} - p_n) = \infty.

Solution

It suffices to show that for every MNM \in \mathbb{N} there is an nn with pn+1pn>Mp_{n+1} - p_n > M.

Put N=(M+1)!N = (M+1)!. By the same argument as in Example 6.5, the MM numbers N+2,N+3,,N+M+1N + 2, N+3, \ldots, N + M + 1 are all composite. Since N+13N + 1 \ge 3, the set of primes not exceeding N+1N+1 is nonempty and finite; let pnp_n be its largest element, so pnN+1p_n \le N + 1.

On the other hand pn+1p_{n+1} is the least prime exceeding N+1N+1, and since N+2,,N+M+1N+2, \ldots, N+M+1 are all composite we get pn+1N+M+2p_{n+1} \ge N + M + 2. Hence

pn+1pn(N+M+2)(N+1)=M+1>Mp_{n+1} - p_n \ge (N + M + 2) - (N+1) = M + 1 > M

As MM was arbitrary, lim supn(pn+1pn)=\limsup_{n\to\infty}(p_{n+1}-p_n) = \infty.

Theorem 6.2 shows that the average gap is about logpn\log p_n, but as this exercise shows, individual gaps become arbitrarily large.

Exercise 8.3Standard

Let nn be a positive integer. Show that if 2n12^n - 1 is prime then nn is prime, and show by an explicit example that the converse fails.

Solution

We prove the contrapositive. Suppose nn is not prime. If n=1n = 1 then 211=12^1 - 1 = 1 is not prime. If nn is composite, write n=abn = ab with 1<a<n1 < a < n and 1<b<n1 < b < n. Substituting x=2x = 2 into the identity

xab1=(xa1)(xa(b1)+xa(b2)++xa+1)x^{ab} - 1 = (x^{a} - 1)\left(x^{a(b-1)} + x^{a(b-2)} + \cdots + x^{a} + 1\right)

shows that 2a12^a - 1 divides 2n12^n - 1. From a>1a > 1 we get 2a13>12^a - 1 \ge 3 > 1, and from a<na < n we get 2a1<2n12^a - 1 < 2^n - 1. So 2n12^n-1 has a divisor other than 11 and itself, and by Definition 2.2 it is not prime.

The converse fails. Here n=11n = 11 is prime, yet

2111=2047=23×892^{11} - 1 = 2047 = 23 \times 89

(indeed 23×89=23×9023=207023=204723 \times 89 = 23\times 90 - 23 = 2070 - 23 = 2047). Primes of the form 2p12^p - 1 are called Mersenne primes; whether infinitely many exist is open.

Exercise 8.4Hard

Let NN be an integer with N1N \ge 1. Show that

π(N)  logN2log2\pi(N) \ \ge\ \frac{\log N}{2\log 2}

(an argument that yields a quantitative form of the infinitude of primes using unique factorization alone, without binomial coefficients).

Solution

Write each integer nn with 1nN1 \le n \le N in the form n=ab2n = a b^{2}, where aa is a squarefree positive integer and bb is a positive integer. Indeed, by Theorem 4.2 we may write n=ppepn = \prod_p p^{e_p} uniquely, so setting

b=ppep/2,a=ppep2ep/2b = \prod_p p^{\lfloor e_p/2\rfloor}, \qquad a = \prod_p p^{e_p - 2\lfloor e_p/2\rfloor}

each exponent in aa is 00 or 11, so aa is squarefree, and ab2=nab^2 = n.

Let us count the possibilities for aa. The prime factors of aa are prime factors of nNn \le N, hence at most NN, and each prime either occurs or does not, so there are at most 2π(N)2^{\pi(N)} candidates for aa. Next count bb. From b2nNb^2 \le n \le N we get bNb \le \sqrt N, so there are at most NN\lfloor\sqrt N\rfloor \le \sqrt N candidates for bb.

The assignment of nn to the pair (a,b)(a,b) is injective (since nn is recovered as ab2ab^2), so

N  2π(N)NN \ \le\ 2^{\pi(N)}\sqrt{N}

Dividing by N\sqrt N gives N2π(N)\sqrt N \le 2^{\pi(N)}, and taking logarithms,

logN2π(N)log2,that isπ(N)logN2log2\frac{\log N}{2} \le \pi(N)\log 2, \qquad \text{that is}\qquad \pi(N) \ge \frac{\log N}{2\log 2}

This bound gives π(N)\pi(N) \to \infty and so reproves the infinitude of primes, but compared with the true size N/logNN/\log N it is overwhelmingly weak. Compare it with Proposition 5.3.

  • 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 lim supxπ(x)logx/xlog4\limsup_{x\to\infty}\pi(x)\log x/x \le \log 4. The key is to estimate not the number of primes but the sum of their logarithms,

θ(x)=pxlogp\theta(x) = \sum_{p \le x}\log p

(Chebyshev’s first function). Since θ(x)=log(pxp)\theta(x) = \log\left(\prod_{p\le x} p\right), what follows is the same as the assertion that the product of the primes up to xx does not exceed 4x4^x.

Step 1: pnp4n\prod_{p\le n} p \le 4^{n} for n1n \ge 1. We argue by strong induction on nn. For n=1n = 1 the left side is the empty product 11 and the right side is 44, so the claim holds. For n=2n = 2 the left side is 22 and the right side is 1616.

Let n3n \ge 3 and assume the claim for all positive integers below nn. If nn is even, then since n3n \ge 3 it is not prime, so pnp=pn1p4n14n\prod_{p\le n} p = \prod_{p \le n-1} p \le 4^{n-1} \le 4^{n}.

If nn is odd, write n=2m+1n = 2m+1 with m1m \ge 1. Consider a prime pp with m+1<p2m+1m + 1 < p \le 2m+1. Such a pp appears as a factor of (2m+1)!(2m+1)!, while p>m+1p > m+1 means it divides neither m!m! nor (m+1)!(m+1)!. Hence

(2m+1m)=(2m+1)!m!(m+1)!\binom{2m+1}{m} = \frac{(2m+1)!}{m!\,(m+1)!}

is divisible by pp (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),

m+1<p2m+1p  (2m+1m),hencem+1<p2m+1p  (2m+1m).\prod_{m+1 < p \le 2m+1} p \ \Bigm|\ \binom{2m+1}{m}, \qquad\text{hence}\qquad \prod_{m+1<p\le 2m+1} p \ \le\ \binom{2m+1}{m}.

Moreover (2m+1m)=(2m+1m+1)\binom{2m+1}{m} = \binom{2m+1}{m+1}, and these are two of the terms of k=02m+1(2m+1k)=22m+1\sum_{k=0}^{2m+1}\binom{2m+1}{k} = 2^{2m+1}, so

2(2m+1m)22m+1,that is(2m+1m)4m.2\binom{2m+1}{m} \le 2^{2m+1}, \qquad \text{that is}\qquad \binom{2m+1}{m}\le 4^{m}.

Applying the inductive hypothesis to m+1<nm+1 < n gives pm+1p4m+1\prod_{p \le m+1} p \le 4^{m+1}, whence

p2m+1p=(pm+1p)(m+1<p2m+1p)4m+14m=42m+1=4n\prod_{p\le 2m+1} p = \left(\prod_{p\le m+1}p\right)\left(\prod_{m+1<p\le 2m+1}p\right) \le 4^{m+1}\cdot 4^{m} = 4^{2m+1} = 4^{n}

which completes the induction. For real x1x \ge 1 we get θ(x)=θ(x)xlog4xlog4\theta(x) = \theta(\lfloor x\rfloor) \le \lfloor x\rfloor \log 4 \le x\log 4.

Step 2: from θ\theta to π\pi. Let 1<y<x1 < y < x. For each prime pp with y<pxy < p \le x we have logp>logy\log p > \log y, so

θ(x)  y<pxlogp > (π(x)π(y))logy\theta(x) \ \ge\ \sum_{y < p \le x}\log p \ >\ (\pi(x) - \pi(y))\log y

Since π(y)y\pi(y) \le y is a trivial bound (the primes up to yy form part of the positive integers up to yy),

π(x) < π(y)+θ(x)logy  y+xlog4logy.\pi(x) \ <\ \pi(y) + \frac{\theta(x)}{\log y} \ \le\ y + \frac{x\log 4}{\log y}.

Step 3: choosing yy. Take y=x/(logx)2y = x/(\log x)^{2} (for xx large enough, 1<y<x1 < y < x). Then logy=logx2loglogx\log y = \log x - 2\log\log x, so

π(x)logxx < 1logx+log412loglogxlogx.\frac{\pi(x)\log x}{x} \ <\ \frac{1}{\log x} + \frac{\log 4}{1 - \dfrac{2\log\log x}{\log x}}.

As xx \to \infty we have loglogx/logx0\log\log x/\log x \to 0, so the right side converges to log4\log 4. Hence lim supxπ(x)logx/xlog4\limsup_{x\to\infty}\pi(x)\log x/x \le \log 4.

Summary. The lower bound log2=0.693\log 2 = 0.693\ldots and the upper bound log4=1.386\log 4 = 1.386\ldots of Proposition 5.3 do indeed straddle the value 11 asserted by Theorem 6.2. Chebyshev refined arguments of this kind as far as 0.921<π(x)logx/x<1.1060.921 < \pi(x)\log x/x < 1.106 for sufficiently large xx, but that the limit is exactly 11 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 LLCPricingTermsLegal notice

© 2026 夢現技研合同会社 ・Feeding the text to an LLM is welcome. Code samples are MIT licensed.