PRIME SPIRALS

GAP 2
96+
×1.0

THE SIEVE

Every view on this page is drawn from one data structure: a sieve of Eratosthenes, computed in your browser the moment you load the page and grown on demand as you zoom out, up to 17 million integers. Strike out the multiples of each prime and what survives is the raw material below — no server, no lookup tables, just O(n log log n) of striking out.

GALAXY · p ↦ (p, p)

Each prime p is drawn in polar coordinates with radius p and angle p radians. The spiral arms are not a property of the primes — they are a property of how badly integers approximate 2π:

6 ≈ 2π  →  6 arms    44⁄7 ≈ 2π  →  44 arms    710⁄113 ≈ 2π  →  280 rays

Consecutive multiples of 44 land almost on top of each other in angle (44 − 7·2π ≈ 0.0177 rad), so each residue class mod 44 traces a slow spiral. Primes avoid the classes sharing a factor with 44, and Dirichlet’s theorem says they spread evenly over the φ(44) = 20 classes that remain — so you see exactly 20 luminous arms, then 280 rays further out where 710⁄113 takes over. The gaps are arithmetic, the arms are Dirichlet.

SACKS · r = √n

Robert Sacks’ 1994 refinement of the Ulam spiral places every integer on a single Archimedean spiral:

r = √n      θ = 2π√n

One full turn passes between consecutive perfect squares, so 1, 4, 9, 16, … line up on a ray heading east. Primes (bright) against composites (faint) then reveal sweeping curves: each curve is a quadratic polynomial in disguise. The densest one is Euler’s famous n² + n + 41, prime for every n from 0 to 39. Why some quadratics are so prime-rich is the substance of the Hardy–Littlewood Conjecture F — still unproven.

ULAM · ℕ → ℤ²

Stanisław Ulam, doodling through a dull conference talk in 1963, wound the integers into a square spiral and marked the primes. The diagonal streaks that jump out are the same phenomenon as the Sacks curves: every diagonal of the square spiral carries the values of a quadratic 4n² + bn + c, and some quadratics simply harbour far more primes than chance suggests. Hover any cell to see its number factorised live.

GAP HEAT

The toggle recolours each prime p by the gap to the next prime. By the prime number theorem the average gap near p grows like ln p — but the fluctuation around that average is wild, and contains famous open problems: the twin prime conjecture says cyan dots (gap 2) never stop appearing, no matter how far you scroll.

ZETA · RIEMANN

The deepest view. Chebyshev’s staircase ψ(x) climbs by log p at every prime power — it encodes the exact position of every prime. Riemann’s explicit formula rebuilds that staircase from the non-trivial zeros ρ = ½ + iγ of the zeta function:

ψ(x) = x − Σρ xρ⁄ρ − log 2π − ½ log(1 − x−2)

Each pair of zeros contributes one oscillating wave — 2√x cos(γ log x − arg ρ)⁄|ρ| — and the animation adds them one at a time: thirty waves in, the smooth curve has grown corners at exactly the primes. The Riemann hypothesis is the claim that every zero lies on the line Re s = ½; equivalently, that the staircase never strays from x by much more than √x — the primes are as orderly as they can possibly be. It has been open since 1859.

THE RENDERING

Canvas 2D with three level-of-detail paths: per-pixel sampling when several integers share a pixel, single-pixel plotting at mid zoom, pre-rendered radial-gradient glow sprites up close. The bloom is a second canvas showing a blurred copy of the first, composited with mix-blend-mode: screen. The Riemann zeros are the first thirty, hard-coded to six decimals; everything else is computed live.