Prime Spiral, commonly known as the Ulam Spiral, is a graphical representation of prime numbers arranged in a spiral format.
- The spiral consists of positive integers arranged in a square pattern, with prime numbers specially marked.
- The visualization reveals clear diagonal, horizontal, and vertical patterns of prime numbers.
- The number spiral is usually started with 1 at the center, but it can begin with any number.

When 41 is placed at the center, one diagonal contains an unbroken sequence of 40 consecutive primes. The sequence runs from 1523 (southwest) through 41 (center) to 1601 (northeast).
This is the longest known example of its kind.
Construction
To construct the prime spiral, we can use the following steps:
Step 1: Start by placing the number 1 at the center of a square grid. Proceed to fill the grid in a spiral pattern with subsequent integers (2, 3, 4, etc.)
Step 2: Identify and mark the prime numbers in the spiral. This can be done by circling them or coloring them differently from the composite numbers.
Step 3: Upon marking the primes, striking diagonal lines become apparent, illustrating a non-random distribution of primes within the spiral.
Using these steps we will get, the spiral of numbers with highlighted primes.
General Visual Representation
When visualizing the prime numbers using the Ulam Spiral (or Prime Spiral), if we extend this arrangement infinitely, intriguing patterns emerge, revealing that prime numbers tend to cluster along certain diagonal lines, although no clear formula or rule governs their exact distribution.
This can be seen in the following larger representation of the Ulam spiral.

Prime Density in the Prime Spiral
| Quadratic Polynomial | Range | Prime Count |
|---|---|---|
| n2 - n + 41 | 0 to 40 | 40 |
| 4n2 - 2n + 41 | 0 to 40 | Approximately 6.6 times the density of random numbers |