Primes
101
Spiral
1
Options
1.0

More about the Ulam spiral

Ulam spiral

The Ulam spiral writes the positive integers in a square, starting at 1 and turning counterclockwise. Mark the primes and they gather on diagonal lines. Each of those lines is a quadratic polynomial. Start the spiral at 41 and one diagonal is Euler's formula, prime for forty steps in a row.

How it works

  1. Open this page and look at the primes. The diagonal streaks are the whole discovery.
  2. Drag to move and scroll to zoom, or open the 5×5 favorite and read every number.
  3. Choose Euler's 40 or click a cell to read its polynomial, then save a PNG.

A spiral of the integers

The path starts at 1. It steps right, then turns left, and each straight run is one step longer than the one before. The first square is the familiar block with 17 in the top left and 25 in the bottom right. Primes are marked. Composites can be shown faintly or hidden, which is the picture Ulam drew in 1963.

Diagonals are formulas

A diagonal of the square is exactly the values of a quadratic \(4n^{2}+bn+c\). Some of those formulas factor and the diagonal is empty. Others, such as Euler's, are prime far more often than a random number of the same size.

Click a cell and the readout gives the formula, the longest prime run on that line, and how that compares with \(1/\ln n\).

Forty primes, one diagonal

\(n^{2}+n+41\) is prime for \(n=0\) through 39. At \(n=40\) the value is \(1{,}681=41^{2}\). On the spiral those numbers are the diagonal \(4n^{2}-2n+41\) once the center cell is 41. The run goes from 1,523 through 41 to 1,601, forty primes, and then it breaks.

Hardy and Littlewood's conjecture predicts that this polynomial is prime nearly seven times as often as chance. It does not prove that the primes continue forever.

Using the app

Drag to move, scroll to zoom, and click a cell to read the quadratic on its diagonal.⁣

Frequently asked questions

What is the Ulam spiral?

A square spiral of the positive integers, devised by Stanisław Ulam in 1963. Start at 1, step right, and turn counterclockwise. Mark the primes and they gather on diagonal, horizontal, and vertical lines.

Why do the primes line up?

Each of those lines is a quadratic polynomial, \(4n^{2}+bn+c\). Some of those formulas are divisible by a small prime almost all the time. Others, including Euler's, almost never are.

What is Euler's run of 40 primes?

\(n^{2}+n+41\) is prime for \(n=0\) through 39, and \(41^{2}\) at \(n=40\). Start the spiral at 41 and those values are one diagonal, \(4n^{2}-2n+41\), from 1,523 through 41 to 1,601.

Does the spiral prove a formula for the primes?

No. It makes the variation visible. Hardy and Littlewood's Conjecture F predicts how rich each quadratic should be. No quadratic has been proved to produce infinitely many primes.

How did Ulam discover the spiral?

By doodling. In 1963 Stanisław Ulam sat through a long, boring talk at a scientific meeting, wrote the numbers in a square spiral and marked the primes, and saw them line up on diagonals. Martin Gardner put the spiral on the cover of Scientific American in March 1964.

烏拉姆螺旋: how do I record a video?

Press the red Record button in the playback bar: it films what the stage shows. Press it again to stop, and the video is saved to your device.Recording is free; you only need to sign in. Without a subscription the video carries a small PictorX logo in a corner.The button beside Record opens the video options: the shape (as shown, square, story 9:16 or wide 16:9), the length (until you stop, one seamless loop, or 5, 10, 15 or 30 seconds for social media) and the file: MP4, WebM or an animated GIF.You can add one of three music tracks: calm, bright or beat.With a fixed length or One loop the video is made frame by frame, so it runs smoothly even on a slow device, and One loop joins its end to its start without a seam.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

前往編輯器