Euler’s Golden Key

A sum over all whole numbers equals a product over all primes. Build both sides, watch them agree, and see how one identity turns questions about primes into questions about a function

Euler’s Golden Key

In 1737 Euler noticed that a sum over every whole number equals a product over every prime. That identity is a door between two worlds, adding and multiplying, analysis and arithmetic, and everything else in this module walks through it. Here you build both sides, run the proof, and work out what the product knows.

Sum Equals Product

Press Play and watch a sum over whole numbers and a product over primes close in on the same value. Then switch to Euler’s sieve and multiply in one factor at a time until a single term is left.

sum over whole numbersproduct over primesζ(s), computed separately
1 + 2−s + 3−s + … + 40−s
= 1.620244
short of ζ(s) by 0.0247 ≤ n1−s/(s − 1) = 0.025
1/(1 − 2−s) × 1/(1 − 3−s) × … × 1/(1 − 37−s)
= 1.6359666
short of ζ(s) by 0.00897 ≤ 0.0409
1.620244
sum of 40 terms
1.635967
product over the 12 primes up to 40
1.644934
ζ(2) = π²/6
2.75
how many times further off the sum is than the product
Two quite different recipes, one adding over every whole number and one multiplying over primes only, close in on the same value. The product gets there with far fewer ingredients.

Lime is a sum the browser has just added up, amber belongs to the primes, and sky blue is ζ(s) computed independently by the Euler–Maclaurin formula. The sieve is carried out on the first 200,000 coefficients of the series, of which the grid shows 120; the terms beyond are estimated from the proportion of numbers that survive, which is why the two readouts differ in their last digits once large primes are in play. Under each number is its term n−s. In the expansion, numbers are capped at 99,999.

Go deeper:Euler’s Identity and Why It Is Unique Factorisation

The identity is ∑ n−s = ∏ (1 − p−s)−1, the sum over all whole numbers n ≥ 1 and the product over all primes p. Euler stated it in Variae observationes circa series infinitas, presented to the St Petersburg Academy in 1737, and his proof is the one the sieve view performs. Multiplying the sum by 2−s gives the sum over even numbers; subtract, and only the odd terms remain. Do the same with 3, then 5, and after every prime the only number with no prime factor is 1.

Read the other way, each factor is a geometric series, (1 − p−s)−1 = 1 + p−s + p−2s + …, and multiplying them all out produces one term for each way of choosing a power of every prime. That every n appears means every whole number is a product of primes; that it appears once means the factorisation is unique. So the identity is the fundamental theorem of arithmetic, rewritten as a statement about functions.

Shortly before, in 1734–35, Euler had solved the Basel problem: the sum of the reciprocals of the squares is π2/6. With the product, that becomes a statement about primes: ∏ (1 − p−2) = 6/π2, which the next demo turns into a probability.

Both sides make sense only for s > 1. At s = 1 the sum is the harmonic series and the product diverges with it. Euler worked with real s. Riemann’s step in 1859 was to let s be a complex number, s = σ + it, where the identity holds for σ > 1 by the same argument, and then to ask what the function does beyond that edge. See also: Continuing Past the Edge.

What the Product Knows

Step through the three views. Watch the sum of the reciprocals of the primes creep upwards, tap the lattice to see which points are visible from the origin, then see where treating primes as independent coins goes wrong.

Sieving: 1 of 10,000,000
0%
—
∑ 1/p over primes p ≤ x, added up here
—
ln ln x + M, with M = 0.2614972128…
—
difference (Mertens’ second theorem says it tends to 0)
—
∏(1 − 1/p) ÷ (e−γ/ln x): the third theorem says it tends to 1
—
primes up to x
—
∑ (ln p)/p − ln x: the first theorem says it stays bounded
3.99
ln ln x + M at x = 1018
5.70
ln ln x + M at x = 10100
counted from the sieveMertens’ formulas
The sum over all whole numbers 1 + ½ + ⅓ + … diverges, so the product over primes cannot have finitely many factors: there are infinitely many primes. Taking logarithms shows more, that ∑ 1/p itself grows without limit. But look how slowly. 0 primes have brought it to 0.000, and by Mertens’ formula the primes below 1018 would bring it only to about 3.99. A sum that diverges like ln ln x is infinite in principle and never large in practice.

Amber is counted exactly from primes the browser sieved; sky blue is a formula; lime is a seeded random sample or a point you chose. The sieve stops at 107, the sample at 2,000,000 tuples, and the ± is one standard error. The exact counts use Möbius inversion over the common factor, ∑ μ(d)⌊N/d⌋k. In the third view the primes are counted in ranges a quarter of a factor of ten wide, the prime number theorem’s prediction is the integral of 1/ln n over the range, and the coins’ prediction is the integral of ∏(1 − 1/p) over primes p ≤ √n.

Go deeper:Mertens, 6/π² and the Limits of Independence

As s falls to 1 the sum grows without limit, like 1/(s − 1). A product of finitely many factors would stay finite, so there are infinitely many primes. Euler went further in the same paper: taking logarithms, ln ζ(s) is ∑ p−s plus something that stays bounded, so the sum of the reciprocals of the primes diverges too. The primes are therefore more numerous than the squares, whose reciprocals add up to a finite number. Euler described the divergence as the logarithm of the logarithm of infinity.

Franz Mertens made that exact in 1874, with three theorems. For primes p ≤ x: ∑ (ln p)/p = ln x + O(1); ∑ 1/p = ln ln x + M + O(1/ln x), with M = 0.2614972128… now called the Meissel–Mertens constant; and ∏ (1 − 1/p) is asymptotic to e−γ/ln x, where γ = 0.5772… is Euler’s constant. These are theorems, proved by elementary means 22 years before the prime number theorem. The demo checks them against primes it sieves.

The chance that a prime p divides each of two random whole numbers is 1/p2. If different primes behave independently, the chance that no prime divides both is ∏ (1 − p−2) = 1/ζ(2) = 6/π2. Here the argument can be made rigorous, as a statement about the proportion of pairs up to N as N grows: Dirichlet proved it in 1849, and Cesàro gave it again in 1881–83. The same reasoning gives 1/ζ(k) for k numbers, and 6/π2 again for the density of squarefree numbers.

Applied to primes themselves, the same heuristic fails. A number near x is prime exactly when no prime up to √x divides it, and independent coins give that the probability ∏ (1 − 1/p), which by Mertens’ third theorem is about 2e−γ/ln x. The true density is 1/ln x, and 2e−γ ≈ 1.1229. The reason is that divisibility by a set of primes is exactly independent only over a stretch as long as their product, and the product of the primes up to √x is vastly larger than x. Primes behave randomly enough for some questions and not for others. How far they depart from random is what the zeros of zeta measure.

The Dirichlet Series Machine

Choose a row of the dictionary and drag the point s around the half-plane to compare both sides. Then multiply two series, and slide the line at the bottom towards 1.2 to watch bumps grow at the heights of the zeros.

Sequence a(n)∑ a(n) n−s equalsSeries, 10,000 termsClosed form at sApart by
the constant 1ζ(s)0.80423 + 0.00845i0.80425 + 0.00844i2.4 × 10⁻⁵
Möbius1/ζ(s)1.24326 − 0.01304i1.24326 − 0.01304i2.2 × 10⁻⁷
number of divisorsζ(s)²0.64652 + 0.01369i0.64675 + 0.01357i2.5 × 10⁻⁴
sum of divisorsζ(s)·ζ(s − 1)needs Re s > 20.54665 + 0.04976i—
Euler’s totientζ(s − 1)/ζ(s)needs Re s > 20.84647 + 0.05919i—
squarefree indicatorζ(s)/ζ(2s)0.77432 − 0.01992i0.77434 − 0.01992i1.5 × 10⁻⁵
Liouvilleζ(2s)/ζ(s)1.29057 + 0.03321i1.29057 + 0.03321i2.4 × 10⁻⁷
von Mangoldt−ζ′(s)/ζ(s)−0.13110 + 0.03765i−0.13108 + 0.03764i2.4 × 10⁻⁵
−0.1311 + 0.0377i
∑ Λ(n) n−s, first 10,000 terms
−0.1311 + 0.0376i
−ζ′(s)/ζ(s) from the computed ζ
2.4 × 10⁻⁵
distance between the two
0.0011
most the missing terms could add (proved bound)
This is the row the rest of the module depends on. Λ(n) is ln p when n is a power of the prime p and 0 otherwise, so the left side knows only about primes. The right side, −ζ′/ζ, is bright wherever ζ has a zero or its pole: look at s = 1 and at the points on the dashed green line Re s = ½.

Multiply two series

The selected row is a(n). Choose b(n); the coefficients of the product series are sums over divisors.

b(n) =
divisor d1234612sum
a(d)00.6931.0990.69300
b(n/d)111111
a(d) × b(n/d)00.6931.0990.693002.485
−0.1059 + 0.0293i
series of a ∗ b at s, 10,000 terms
−0.1057 + 0.0292i
−ζ′(s)/ζ(s) × ζ(s) at s
2.2 × 10⁻⁴
distance between the two
For every n up to 10,000, Λ(n) ∗ 1 equals ln n, whose series is −ζ′(s). That is the same statement as −ζ′(s)/ζ(s) × ζ(s) = −ζ′(s). Multiplying m−s by k−s gives (mk)−s, so the coefficient of n−s in a product collects every way of writing n as d × n/d.

The zeros, felt from outside the strip

Add up ∑ Λ(n) n−s along a vertical line to the right of 1 and plot its size against the height.

series over 79 prime powers|ζ′/ζ| from the computed ζzeros found by this browser
The amber curve is made from nothing but the logarithms of primes. The fuchsia lines are the heights of the first 13 zeros of ζ, found separately on the line Re s = ½: 14.135, 21.022, 25.011 … Slide σ towards 1.2 and the bumps under them sharpen; add more prime powers and the amber curve closes on the blue one. A logarithmic derivative has a pole at every zero and every pole of its function, so a series about primes is forced to know where the zeros are.

Amber is a sum over whole numbers or primes added up here, sky blue a value built from ζ, lime the product sequence, fuchsia a zero. ζ is computed by the Euler–Maclaurin formula and ζ′ by differentiating that formula term by term, with no finite differences; both are good to about eleven figures. Each series stops at 10,000 terms, and the teal figure is a proved bound on the rest from the growth of the sequence, so close to the red line the agreement is poor and the bound says so. The plane is coloured by the closed form on a 100 × 72 grid: hue is the argument, dark is near zero, bright is large. These are double-precision computations, not proofs.

Go deeper:Dirichlet Series, Möbius Inversion and −ζ′/ζ

A Dirichlet series is a sum ∑ a(n) n−s. Where a power series converges inside a disc, a Dirichlet series converges in a half-plane Re s > σc, and absolutely in a possibly smaller half-plane Re s > σa, with σa − σc at most 1. Dirichlet introduced them in 1837 to prove that every arithmetic progression a, a + q, a + 2q, … with a and q coprime contains infinitely many primes. Since m−s k−s = (mk)−s, the product of two such series has coefficients (a ∗ b)(n) = ∑ a(d) b(n/d), summed over the divisors d of n: multiplication of functions is convolution of sequences.

That one rule generates the table. ζ(s)2 has coefficients 1 ∗ 1 = d(n), the number of divisors. ζ(s)ζ(s − 1) has coefficients 1 ∗ n = σ(n). The inverse of ζ comes from expanding the Euler product, ∏ (1 − p−s) = ∑ μ(n) n−s, where μ(n) is (−1)k for a product of k distinct primes and 0 if a square divides n. So μ ∗ 1 is the sequence 1, 0, 0, …, and Möbius inversion, which recovers g from f = g ∗ 1 as g = f ∗ μ, is nothing more than division by ζ.

The last row matters most. The logarithm of the Euler product is ln ζ(s) = ∑ p−ks/k, summed over primes p and k ≥ 1, and differentiating gives −ζ′(s)/ζ(s) = ∑ Λ(n) n−s, where the von Mangoldt function Λ(n) is ln p when n is a power of p and 0 otherwise. The left side of that equation is a function of a complex variable, with a pole at every zero ρ of ζ and another at s = 1, where it behaves like 1/(s − 1). The right side is a list of primes. Every later lesson exploits this: the primes on one side are tied to the zeros and the pole on the other (See also: Primes from Zeros).

The dictionary also shows how the Riemann hypothesis can be restated. The series ∑ μ(n) n−s is proved to converge for Re s > 1. It converges for every Re s > ½ if and only if the Riemann hypothesis holds: 1/ζ has a pole at each zero of ζ, so a zero off the critical line would block the convergence, and the converse is a theorem too. Until the hypothesis was proved in November 2026, nobody could show that the series converges anywhere to the left of the line Re s = 1; now it is a theorem that it converges all the way to Re s = ½ (See also: The Hypothesis in Disguise, and What Is Actually Known). See also: Number Theory, for multiplicative functions and a first look at the zeta function.

Key Takeaways

  • For Re s > 1 the sum of n−s over whole numbers equals the product of (1 − p−s)−1 over primes, and that identity is unique factorisation.
  • Euler’s proof is a sieve: each factor (1 − p−s) cancels the terms divisible by p, until only 1 remains.
  • The product implies that the reciprocals of the primes diverge like ln ln x and that k random numbers share no factor with probability 1/ζ(k).
  • −ζ′/ζ is a series over prime powers alone, and its poles are the zeros and the pole of ζ, so primes and zeros are tied together.

Spot a mistake or have an idea?

Search