The Ulam Spiral

… and many other spirals¬†
inspired by it …


Purpose of this website:
To expose,

  1. Why the rows of prime numbers located on the Ulam Spiral consist of fragments of various lengths interspaced by empty stretches of various lengths.
  2. Why the rows of prime numbers located on the Ulam Spiral are oriented in the 2 diagonal directions, and no other directions.

Numbers adjacent to a multiple of 6.

All prime numbers -except 2 & 3- are 1-less or 1-more than a multiple of 6, thus these numbers are adjacent to a multiple of 6.

Many composite numbers are also adjacent to a multiple of 6.

For convenience:
all these adjacent numbers, prime- & composite-, can be referred to as the “Adjacents”, and “Multiples of 6” can be referred to simply as “6-folds”.



Fig. -1.

The 6-folds are emplaced in the spiral in
a regular array of numbers.
Because of their adjacency,
the array of adjacents can be
visualized as extending thru out the
array of 6-folds in the manner of
ivy intertwined thru out a trellis.

The array of 6-folds determines
the structure of the array of adjacents.
Seeing the array of 6-folds first of all
is thus an optimal practice when
wishing to understand the
structure manifested by the array of adjacents.

The Figure at left shows
the 6-folds emplaced in the Ulam spiral,
showing these only.

Color-coded number-groups:
click below for show/no-show settings.

display control


prime adjacents

composite adjacents

Click on the green button next to “prime adjacents” in “display control” to display the prime adjacents, and their adjacency to the 6-folds now is clear to see.

Next, click on the button for “composite adjacents” to display these. To best see the array of all adjacents as a whole it is helpful to click on the dark green button, the left one of the pair. Subsequently, that array can be seen even more clearly by clicking off the “6-folds”.

At this point, it is good to change the coloration of the composite adjacents by clicking on the light green button, the right one of the pair. The intermingling of the prime- & composite adjacents in one common array can now be clearly seen.

the prime adjacents & the composite adjacents can each be seen separately by using these buttons.


Upon seeing the rows of prime adjacents by themselves the following should be obvious:

  1. The fragmentary condition of these rows is caused by the absence of the composite adjacents.
  2. These row-fragments are orientated in diagonal directions because the diagonal orientations of the endless rows seen in the figure above are preserved in these row-fragments.

Upon seeing the rows of composite adjacents by themselves it should be obvious that all of the above can be repeated, except in that case the condition per 1) is caused by the absence of the prime adjacents.

Thus there is nothing mysterious about these fragmentary rows and their diagonal orientations. 



Fig. -2.

The Figure above -when shown with only the prime adjacents- presents a spiral that is identical to the Ulam spiral except for the following differences:

  1. “1” is represented as a member of that set of prime numbers, and therefore color-coded green, because it is an adjacent of “0”, which is a 6-fold since 0 x 6 = 0. See also in figure at left.
  2. “2” & “3” are not represented because they are not adjacents of a 6-fold, and thus as a species, they are totally different from all the other numbers. They are shown in the figure at left, with purple background.

As can be seen in the Figure at left:
the omission of “1” would constitute an incompletion in the pattern of the array and adding “2” & “3” would constitute a distraction, geometrically & algebraically.

People trying to find patterns in the distribution of primes, in the spiral or elsewhere, might want to take note of these concerns.

Interestingly, the pattern in the Figure at left calls to mind a group of green/red turtles slowly crawling counter-clockwise along the spiral, heading towards larger numbers. As they cross sector line -3 they are required to make a sharp 90° bend leaving them severely distorted.



Fig. -3.

The Figure at left shows the low end of
an endless- and exhaustive stack of
segments from the numbers-line
starting and ending with a 6-fold,
with these 6-folds being each others neighbor.

The 6-folds are contained in the first & last columns.
Abutting these are columns containing the adjacents.
In the midst of these are 3 contiguous columns containing
all the intervening numbers.

In this scheme the numbers “2” & “3”
can be regarded as being members of
the group of intervening numbers,
members that happen to be “prime”
simply by being to small to contain factors.

Certain 6-folds have 
a prime adjacent that is 1-less in value or
a prime adjacent that is 1-more in value.
In some cases a 6-fold might have both.
In that case the result is
a pair of prime adjacents, differing by 2.
Thus there is nothing mysterious about
the existence of such pairs. 

Suggested number-definitions:

Prime number:
Any whole number larger than 4
that cannot be evenly divided by
any whole number larger than 1.

Quasi prime:
1, 2, 3.

Composite number:
Any whole number larger than 3
that can be evenly divided by
one- or more whole numbers larger than 1.