Prime Number Spirals

In this project, I attempted to find formulas for arithmetic sequences with a high frequency of prime numbers. I found these formulas by creating numerical spirals similar to Ulam’s spiral, formed from three basic geometric shapes—hexagons, squares, and triangles. I chose these specific shapes because a regular tessellation of a surface can only be achieved using these three shapes. In other words: only these shapes can be arranged side by side without leaving any gaps.

HEXAGONAL SPIRAL
First, I created a single hexagon and wrote the number 1 inside it. Along the entire outer perimeter of this hexagon, I drew additional hexagons and wrote positive natural numbers inside them in a clockwise direction so that the number 1 was always aligned vertically in a single column. I repeated this process until the figure was large enough.

Then I marked all the hexagons containing a prime number with green.

A remarkable pattern suddenly emerged in this figure. I noticed that in the two columns at the top left, there are numerical sequences with an arithmetic progression whose common difference is 6 (highlighted in red), which contain a high frequency of prime numbers. The formula for calculating the nth term in the left column is a(n) = 6n + 1, and in the right column, a(n) = 6n + 5. I searched for these two numerical sequences on OEIS (Online Encyclopedia of Integer Sequences) and found that both are already in the database under codes A016921 and A016969. I also found an interesting claim online: the set of the sequences a(n) = 6n + 1 and a(n) = 6n + 5 together contains all prime numbers greater than 3. In addition to these two interesting columns containing many prime numbers, I also discovered a sequence of odd numbers that contains no prime numbers (highlighted in blue). The formula for calculating the nth term in the blue column is a(n) = 6n + 3. I later found this sequence in the OEIS database under code A016945.

SQUARE SPIRAL
In the same way, I constructed a square spiral in which these three sequences also appeared.

TRIANGULAR SPIRAL
In this spiral, the sequences a(n) = 6n + 1 and a(n) = 6n + 5 appeared again, but combined together. This combination occurred because at every even step of the spiral’s construction, the triangle rotates by 180° (some triangles are pointed upward, others downward).

Here you can play around with an interactive demonstration: