Ulam Spiral
Writing the integers in a square spiral and marking the primes reveals startling diagonal alignments where order seems to leak out of randomness.
Contents
Ulam Spiral
The Ulam spiral is one of the most famous accidental discoveries in mathematics. In 1963, bored during a lecture, Stanisław Ulam began writing the integers in a square spiral and idly circling the primes. He expected a random scatter. Instead the primes lined up along diagonals — long, conspicuous streaks that have no business appearing in something as irregular as the primes. The pattern is real, partial, and still not fully explained.
Coil the integers, mark the primes
Start with 1 at the center and spiral outward: 2 to its right, then up, left, down, around and around. Color a cell whenever its number is prime. The diagonals emerge on their own.
Why the diagonals?
The diagonals are not an illusion — they trace quadratic polynomials. Moving along a diagonal of the spiral steps you through values of an expression like 4k^2 + bk + c. Some of these quadratics are unusually rich in primes; the most celebrated is Euler's polynomial
which is prime for every k from 0 to 39 — forty primes in a row. Each prime-dense quadratic paints one bright diagonal across the spiral.
Same primes, different canvas
The effect is not unique to the square spiral. Plot the primes on a polar spiral, or with a hexagonal coiling, and different alignments appear or dissolve — proof that the diagonals are partly an artifact of how we arrange the integers, and partly a genuine fact about prime-dense quadratics. The honest summary: the primes are neither random nor regular, and the Ulam spiral is the clearest picture we have of that in-between.