← Back to Paradoxes

The Ulam Spiral

✨ Prime Numbers Hide in Diagonal Lines ✨

Arrange integers in a spiral. Highlight the primes. Mysterious diagonal patterns emerge— patterns that connect to deep unsolved problems in mathematics. Discovered by doodling during a boring lecture in 1963.

0
Numbers
0
Primes
0%
Prime %
-
Hover

Spiral Size

Starting Number

Highlight Polynomials

Why Do Diagonals Appear?

🎯 Discovered While Bored

In 1963, mathematician Stanisław Ulam was attending a "long and boring" scientific meeting. To pass the time, he started doodling numbers in a spiral pattern on graph paper. When he circled the primes, he was shocked to see diagonal lines emerging. He ran the pattern on a MANIAC II computer—same result. Martin Gardner later popularized it in Scientific American.

Quadratic Polynomials

Diagonals in the spiral correspond to quadratic polynomials of the form 4n² + bn + c. Some polynomials (like Euler's famous n² - n + 41) produce unusually many primes, creating visible streaks.

Hardy-Littlewood Conjecture

This 1923 conjecture predicts which quadratics produce many primes. It explains the Ulam spiral patterns—but remains unproven after 100 years!

Odd vs Even Diagonals

All primes except 2 are odd. In the spiral, diagonals alternate between all-odd and all-even numbers. So half the diagonals have zero primes (except 2)!

Why Spirals Work

The spiral arrangement maps integers to 2D coordinates where quadratic progressions become straight lines. Other arrangements don't reveal this pattern as clearly.

Euler's Prime-Generating Polynomial

f(n) = n² - n + 41
Produces primes for n = 0, 1, 2, ..., 40 (all 40 values!)
This creates a diagonal with 40 consecutive primes in the spiral.