On this page
Ask how many primes there are below a number and you get two answers: the exact count, which needs a computer for big numbers, and a one-line estimate, x/ln x, that a calculator can handle. Here they are side by side, with what the prime number theorem does and does not promise.
What is the prime-counting function π(x)?
The prime-counting function π(x) is the number of primes less than or equal to x, as defined on Wolfram MathWorld's prime number theorem page. Count by hand and π(10) = 4, because the primes up to 10 are 2, 3, 5 and 7. The number 1 is left out, for the reasons in why 1 is not a prime number.
How many primes are there below 1,000, a million and a billion?
The exact values of π(x) at every power of ten up to 10^29 are listed in the OEIS sequence A006880, number of primes below 10^n. Here are the ones worth remembering:
Below 100: 25 primes.
Below 1,000: 168 primes.
Below 10,000: 1,229 primes.
Below 1,000,000: 78,498 primes.
Below 1,000,000,000: 50,847,534 primes.
The same figures appear in the tables on PrimePages, How many primes are there?. Notice how the primes thin out: a quarter of the numbers up to 100 are prime, but only about 5% of the numbers up to a billion.
How do you estimate π(x) with x/ln x?
Here is the estimate worked through for one million, using the counts from OEIS A006880:
ln(1,000,000) = 6 × ln 10 ≈ 6 × 2.3026 = 13.8155.
1,000,000 ÷ 13.8155 ≈ 72,382.
The true count is 78,498, so the estimate is short by 6,116, about 8%.
PrimePages lists the same 72,382, and shows that a small change, x/(ln x − 1), gives 78,030, much closer. Now try one yourself. For 10,000, ln x ≈ 9.2103, so x/ln x ≈ 1,086 against a true 1,229. For a billion, 10^9 ÷ 20.723 ≈ 48.25 million against a true 50.85 million: still short, but now by about 5%.
What does the prime number theorem actually say?
The prime number theorem says π(x) is asymptotic to x/ln x, meaning the ratio π(x) ÷ (x/ln x) tends to 1 as x grows (PrimePages). Using the OEIS counts, that ratio is 1.16 at 1,000, 1.08 at a million, 1.054 at a billion and still 1.024 at 10^19. It is the same kind of statement as Stirling's approximation for n!: a ratio that tends to 1, not a difference that shrinks to 0.
A handy way to read it: the density of primes near x is about 1/ln x (PrimePages). Near a billion, ln x ≈ 20.7, so roughly 1 number in 21 is prime. The same page gives a second consequence: the nth prime is about n ln n. For n = 1,000,000 that predicts about 13.8 million; the actual millionth prime is 15,485,863.
The idea is old. MathWorld records that Gauss proposed π(n) ~ n/ln n in 1792, when he was 15. PrimePages dates Legendre's first published conjecture, a formula fitted to his tables, to 1798, and records that Hadamard and de la Vallée Poussin independently proved the theorem in 1896, using Riemann's work.
What does the prime number theorem not say?
Every point below comes from PrimePages or MathWorld:
It does not give the exact count. PrimePages warns that a ~ b does not mean a − b is small; at a billion the gap between π(x) and x/ln x is over 2.5 million.
It does not make x/ln x the best formula. x/ln x is below π(x) for every x above 10. Gauss's logarithmic integral Li(x) gives 50,849,235 at a billion, only 1,701 too high.
It does not say Li(x) always overshoots. Li(x) is above π(x) for every value in the tables, but Littlewood proved in 1914 that the inequality reverses infinitely often.
It does not say where the next prime is. PrimePages notes there are arbitrarily large gaps between primes; the theorem describes the average spacing, not any single gap.
It does not pin down the error. Koch showed in 1901 that if the Riemann hypothesis is true, the error in Li(x) is at most a constant times √x ln x for large x.
How can you check the estimate yourself?
Run a sieve of Eratosthenes up to 100 on paper and check that you get 25 primes, the count listed in OEIS A006880.
Estimate π(100) with x/ln x (100 ÷ 4.605 ≈ 21.7) and work out the ratio 25 ÷ 21.7.
Repeat step 2 for 10,000 and one million using the counts above, and watch the ratio fall towards 1.
If logarithms, limits or the word asymptotic still feel shaky, the Fermi Concept Library has a lesson for each concept in mathematics, with its place in the map. For practice, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



