Prime Number Theorem Explained: Formula and Examples
Quick answer: The prime number theorem says that the number of primes up to x, written π(x), is approximately x / ln x, in the sense that their ratio tends to 1 as x grows. Equivalently, the proportion of primes among the numbers up to N is about 1 / ln N. Gauss and Legendre conjectured it around 1800, and Jacques Hadamard and Charles de la Vallée Poussin proved it independently in 1896.
Primes thin out as numbers grow: a quarter of the numbers up to 100 are prime, but only about 5% of those up to a billion. Is there a pattern to how fast they thin out? The prime number theorem gives the answer, and it is one of the most beautiful results in mathematics.
The Statement
Let \(\pi(x)\) be the number of primes less than or equal to \(x\). Then
\[ \pi(x) \sim \frac{x}{\ln x}, \quad \text{meaning} \quad \lim_{x \to \infty} \frac{\pi(x)}{x / \ln x} = 1. \]
Here \(\ln x\) is the natural logarithm. An even better approximation is the logarithmic integral \(\operatorname{li}(x) = \int_0^x \frac{dt}{\ln t}\) (taken as a principal value).
Check It With Real Numbers
| \(x\) | \(\pi(x)\) | \(x / \ln x\) | \(\operatorname{li}(x)\) |
|---|---|---|---|
| 1,000 | 168 | about 145 | about 178 |
| 1,000,000 | 78,498 | about 72,382 | about 78,628 |
| 1,000,000,000 | 50,847,534 | about 48,254,942 | about 50,849,235 |
Table values of \(\operatorname{li}(x)\) use the principal-value integral from 0; starting at 2 instead lowers each by about 1.045. The ratio \(\pi(x) / (x/\ln x)\) is 1.16 at a thousand, 1.08 at a million and 1.05 at a billion: slowly approaching 1. The logarithmic integral is far more accurate.
What It Means in Practice
- Proportion of primes: among the numbers up to \(N\), the fraction that are prime is \(\pi(N)/N \approx 1/\ln N\). Up to a million the true fraction is 7.85%, and \(1/\ln N\) gives 7.24%. As a local heuristic, about 1 in 14 numbers near a million is prime (\(\ln 10^6 \approx 13.8\)), though short stretches vary.
- Average gap: consecutive primes near \(x\) are about \(\ln x\) apart on average.
- The \(n\)th prime: \(p_n \approx n \ln n\). For \(n = 1{,}000\) this gives about 6,908; the true 1,000th prime is 7,919.
Cryptography relies on this: it tells you how many random tries it takes to find a large prime for an RSA key.
A Short History
| Year | Step |
|---|---|
| 1792 to 1793 | Carl Friedrich Gauss, about 15 or 16 by his later recollection, notices primes near \(x\) have density about \(1/\ln x\) |
| 1798; 1808 | Adrien-Marie Legendre publishes an approximation, in 1808 \(x / (\ln x – 1.08366)\) |
| 1850s | Pafnuty Chebyshev proves \(\pi(x)\) is within constant factors of \(x/\ln x\) |
| 1859 | Bernhard Riemann links primes to the zeros of the zeta function |
| 1896 | Jacques Hadamard and Charles de la Vallée Poussin prove the theorem independently, using complex analysis |
| 1948 to 1949 | Paul Erdős and Atle Selberg find “elementary” proofs without complex analysis |
The key step in 1896 was showing that the Riemann zeta function has no zeros on the line where the real part equals 1.
The Error Term and the Riemann Hypothesis
How far can \(\pi(x)\) stray from \(\operatorname{li}(x)\)? The Riemann Hypothesis is equivalent to
\[ \pi(x) = \operatorname{li}(x) + O(\sqrt{x} \ln x), \]
an upper bound on the error up to a constant. The prime number theorem itself was proved in 1896 without RH. On November 21, 2026, the Lean and Mathlib communities certified a formal proof of RH released by Levent Alpöge; the Clay Institute still lists RH as unsolved pending its own process.
Computer-Checked Proofs
The prime number theorem was first checked by computer in 2004 (Jeremy Avigad and colleagues, in Isabelle; paper 2005). In January 2024, Terence Tao and Alex Kontorovich launched a Lean project to formalize the stronger version with an error term. In September 2025, Math, Inc. reported that its AI agent Gauss completed that strong PNT formalization in about three weeks, roughly 25,000 lines of Lean, with human scaffolding and review and building on the existing PrimeNumberTheoremAnd project. See our Lean explainer.
Common Misconceptions
“x/ln x gives the exact count.” No. It is an approximation whose relative error shrinks; the absolute difference actually grows.
“Primes eventually run out.” No. Euclid proved there are infinitely many; the theorem says how sparse they become.
Watch: The Prime Number Theorem in Video
If you learn better by watching, these videos are worth your time.
Check Your Understanding
Five quick questions to see how much of this has stuck. Pick an answer and press Submit; you will see a short explanation either way.
Answer each question and press Submit to see your result right away.
Frequently Asked Questions
What is the prime number theorem in simple terms?
It says the number of primes up to x is roughly x divided by the natural logarithm of x, and the approximation gets better in relative terms as x grows.
Who proved the prime number theorem?
Jacques Hadamard and Charles de la Vallée Poussin proved it independently in 1896. Erdős and Selberg found elementary proofs in 1948 to 1949.
How is the prime number theorem related to the Riemann Hypothesis?
The prime number theorem follows from knowing zeta has no zeros with real part 1. The Riemann Hypothesis, about all nontrivial zeros, would give the best possible error term, about √x ln x.
How many primes are there below one billion?
There are 50,847,534 primes below one billion. The estimate x / ln x gives about 48.25 million, and li(x) gives about 50.85 million.
Keep Exploring
- Riemann Hypothesis Solved? What’s Verified in 2026
- Legendre’s Conjecture: A Prime Between Every Two Squares?
- Largest Known Prime Number (2026): 41,024,320 Digits
Sources and Further Reading
Related to This Article
More math articles
- Balancing Probabilities: A Comprehensive Guide to the Expected Value of Random Variables
- CPA REG Agency vs Contract Liability: Read the Legal Relationship (2027 Prep)
- The Best Grade 4 ELA Practice Tests for West Virginia Students
- Explicit Details
- South Dakota Smarter Balanced Grade 7 Math Worksheets: 95 Free Printable PDFs
- Finding Area of Compound Figures
- Dual federalism
- Presidential Communication: The Bully Pulpit and Its Limits
- Other Topics Puzzle – Challenge 97
- 5th Grade GMAS Math Worksheets: FREE & Printable


What people say about "Prime Number Theorem Explained: Formula and Examples - Effortless Math"?
No one replied yet.