The Mystery

In 1963, mathematician Stanislaw Ulam was bored during a meeting. He started doodling: writing numbers in a spiral pattern and circling the primes.

What he noticed changed how we visualize primes forever: they line up on diagonal lines. This shouldn't happen. Primes are "random." Yet the pattern persists at all scales.

The diagonal alignments relate to quadratic polynomials that generate primes, but there's no complete explanation for why the visual pattern is so striking. It remains one of mathematics' beautiful mysteries.

Interactive Visualization

Green dots are primes. Gray dots are composite numbers. Use controls to explore.

Hover over the spiral to see number details

What You're Seeing

🎯 Center Point

The spiral starts at 1 in the center and spirals outward: right, up, left, left, down, down, right, right, right...

📐 Diagonal Lines

Notice how primes cluster along certain diagonal lines. These correspond to quadratic polynomials like n² + n + 41.

🔍 Scale Independence

Try different spiral sizes. The diagonal patterns persist whether you're looking at 51×51 or 201×201. The mystery deepens.

🌌 Visual Emergence

This isn't a programmed pattern. It emerges purely from the definition of primes and the spiral arrangement. Pure emergence.

About This Visualization

This interactive spiral is rendered in real-time using JavaScript and HTML5 Canvas. Every prime is computed on-the-fly using the Sieve of Eratosthenes—the same algorithm Eratosthenes invented in 240 BC.

Some algorithms are timeless. The Sieve is still the fastest way to find all primes up to a limit, over 2,200 years after its invention.

Explore More Patterns →