🌀 Prime Spiral
In 1963 the mathematician Stanisław Ulam was doodling through a dull talk. He wrote the numbers in a square spiral out from the center, then circled the primes. Primes are supposed to look random, yet his kept falling into diagonal lines.
How the picture is made
- Write 1 in the middle of a sheet of graph paper.
- Spiral outward clockwise (right, down, left, up) and fill in 2, 3, 4… one square at a time.
- Light up the primes, leave everything else dark, then erase the numbers.
That little grid holds the first 16 numbers. The big picture below follows the same rule all the way to 40,000, and every bright dot is a prime. Nobody drew the diagonals in; the dots fall into line on their own. The colors shift ring by ring purely for looks and mean nothing mathematically.
Why the diagonals?
Every diagonal is a quadratic
Walk along any diagonal and the numbers you meet follow a formula of the form 4n² + bn + c. So “primes lining up on diagonals” really means some quadratics are unusually good at producing primes.
Half the diagonals never stand a chance
Odd and even numbers alternate around the spiral, so some diagonals are made entirely of even numbers, and apart from 2 no even number is prime. That is the main reason the diagonals run bright, dark, bright, dark.
Bright diagonals dodge small factors
A number that isn’t divisible by small primes like 2, 3, 5 or 7 has a much better shot at being prime. Some formulas are built so their values can never be divisible by those primes. The most famous one is Euler’s:
n² + n + 41
It is never divisible by any prime up to 37. For n = 0 through 39 it spits out 40 primes in a row, and the streak only breaks at n = 40, where it gives 41². Start the spiral at 41 instead of 1 and those 40 primes all land on a single diagonal.
What nobody has proved yet
In 1923 Hardy and Littlewood conjectured a formula for how densely primes should crowd each diagonal. It matches the data remarkably well, but it is still unproven. In fact, no one has managed to prove that even one such quadratic produces infinitely many primes. Whether n² + 1 does is a famous open problem.