Number Theory
Advanced

Prime Number Theorem

Approximates the number of primes below x.

Formula

π(x)∼xln⁡x\pi(x) \sim \frac{x}{\ln x}

Variables

xUpper bound
\pi(x)Prime count

Example

Up to 100 there are 25 primes; the theorem estimates 100/ln100 ≈ 22.

How it works

The Prime Number Theorem says that primes become less frequent in a very regular way: near a large number x, the chance that a number is prime is about 1/ln(x), so the total count of primes up to x is about x/ln(x). This is not an exact count but an asymptotic estimate, meaning the ratio \u03c0(x) / (x/ln x) tends to 1 as x grows. It comes from deep connections between prime distribution and the behavior of the Riemann zeta function, which reveal that primes are irregular locally but highly predictable on a large scale.

When to use it

Use this when you need a quick estimate for how many primes lie below a large upper bound, especially in analytic number theory, computational experiments, or rough complexity estimates involving primes. It is most reliable for large x, where the approximation improves noticeably.

Worked example, step by step

Estimate how many primes are below 1,000,000. Step 1: Identify x = 1,000,000. Step 2: Compute ln(x) = ln(1,000,000) \u2248 13.8155. Step 3: Apply the Prime Number Theorem: \u03c0(x) \u2248 x / ln(x). Step 4: \u03c0(1,000,000) \u2248 1,000,000 / 13.8155 \u2248 72,382. Step 5: So the theorem predicts about 72,382 primes below 1,000,000.

Common mistakes to avoid

  • Using log base 10 instead of the natural logarithm ln
  • Treating x/ln(x) as an exact count rather than an approximation
  • Applying the estimate to small x where the error can be relatively large

Did You Know?

The prime number theorem reveals that primes thin out but never stop — Euclid proved there are infinitely many.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026