← all video summaries
3Blue1Brown

Prime Spirals — How π Hides Inside the Primes

Plot prime numbers as polar coordinates and something unexpected appears — golden spirals, then straight rays, all governed by rational approximations of 2π and a 19th-century theorem about primes.

Watch on YouTube
TL;DR

TL;DR

  1. Primes plotted as (p, p) in polar coordinates form golden spiral arms — not from the primes, but from integers approximating 2π
  2. At medium scale, 22/7 ≈ π creates 20 visible arms = φ(44)
  3. At large scale, 355/113 ≈ 2π produces 280 nearly-straight rays = φ(710)
  4. Missing arms and gaps are simply residue classes that can't contain primes (evens, multiples of 11, 71)
  5. The primes within those surviving classes are evenly distributed — Dirichlet's theorem (1837), proved with complex analysis

01 · Polar Primes

The Setup

Plot every prime number p as a point at distance p and angle p radians in polar coordinates. What you get is a spiral pattern — clean, galactic, and completely unexplained by the primes themselves.

Each prime labeled — 5, 7, 11, 13, 19, 31 — spiraling outward from the origin.00:02:13

02 · Six Arms, Two Survivors

Residue Classes Mod 6

Zoom into the smaller-scale spirals. There are six arms, each corresponding to a residue class mod 6 — numbers sharing the same remainder when divided by 6. But prime numbers can only live in two of them: those that are 1 or 5 above a multiple of 6. All the others are ruled out by basic divisibility.

Residue classes mod 6: each arm is numbers with the same remainder when divided by 6.00:04:40

03 · Twenty Arms, Euler's Totient

Residue Classes Mod 44

Zoom further. 44 radians is just barely above 7 full turns — the famous 22/7 ≈ π approximation at work. The arms are now residue classes mod 44. But primes eliminate many of them: evens (residues 0, 2, 4, …), multiples of 11 (residues 11, 33). What remains are exactly the numbers co-prime to 44 — countable with Euler's totient function:

φ(44) = 20

Those 20 surviving classes each get a spiral arm.

The golden-highlighted arms are the 20 residue classes mod 44 that are co-prime to 44.00:09:14

04 · 280 Rays

355/113 ≈ 2π at Large Scale

Go even farther out. 710 radians is incredibly close to 113 full turns — making 355/113 one of the best rational approximations of π you'll find. The spirals now look like straight rays.

710/113 ≈ 2π and 355/113 ≈ π — the approximation is so good the rays look straight.00:11:42

The 280 rays are φ(710) — the residue classes mod 710 that don't share factors with 710 (factors: 2, 5, 71). Primes can't live in the eliminated classes. But within each surviving class, the primes appear evenly.

Primes seem to be randomly distributed within each of those arms.

05 · Equidistribution

Dirichlet's Theorem

This is the deep part. Primes are equidistributed among the residue classes co-prime to n — each of the φ(n) classes gets its fair share. Dirichlet proved this in 1837 using complex analysis, bridging discrete number theory with continuous calculus in a way that was then — and still is — unexpected.

Histogram: as more primes pass through, the proportion in each allowable last-digit class converges to 25%.00:15:40
Dirichlet's theoremFor any n, primes are asymptotically equally distributed among the φ(n) residue classes that are co-prime to n. First proved by Dirichlet in 1837.

06 · Play as a Path to Depth

Plotting (p, p) in polar coordinates is arbitrary. The spirals come from integer arithmetic approximating 2π, not from anything intrinsic to the primes. But that arbitrary play — the kind of curiosity sparked by a Math Stack Exchange question — led to one of the crowning jewels of analytic number theory.

The golden spiral rays at the large scale — a visual testament to how good 355/113 approximates 2π.00:19:57
What it means for a piece of math to be important and deep is that it connects to many other topics. So even an arbitrary exploration of numbers, as long as it's not too arbitrary, has a chance of stumbling into something meaningful.— Grant Sanderson
Residue class mod n

Numbers sharing the same remainder when divided by n — each becomes a spiral arm in polar plot

Euler's totient φ(n)

Count of integers from 1 to n that are co-prime to n — determines how many arms survive prime filtering

Rational approximations of 2π

22/7 → 20 arms; 355/113 → 280 rays. Better approximations = more, straighter rays

Dirichlet's theorem

Primes distribute equally among surviving residue classes — proved via complex analysis, 1837