Unexpectedly Intriguing!
26 May 2023
Primes vs Composites by David Eppstein via WikiMedia Commons - https://commons.wikimedia.org/wiki/File:Primes-vs-composites.svg

If you ever want to go down a very deep rabbit hole, and you're mathematically minded, searching out patterns in prime numbers is a great place to begin.

In fact, if you just want to start somewhere simple, try this. Set up a table with six columns. Starting in the first row of the table, with the first prime number, 2, number all the boxes of the table from left to right. Then, move down to the next row of the table and continue the numbering process. Add as many rows as you like.

When you've made a decent-sized table, stop adding rows and go back to visually distinguish the prime numbers among all the numbers you wrote. You should pretty quickly find your first patterns.

We did that exercise, using just the numbers from 2 to 211. Here's the table we generated, along with some of the patterns we were able to identify:

Patterns of Prime Numbers (Among numbers 2 through 211)

Except for the first row, which has four prime numbers (2, 3, 5, and 7), each subsequent row contains no more than two prime numbers in it. Each of those prime numbers appear in just two columns that we've identifed as Set D, which starts with 5 in the first row, and Set F, which starts with 7.

By setting up the list of numbers this way, we've effectively sieved the full set of integers to exclude multiples of 2 (Set A, Set C, and Set E) and multiples of 3 (Set B and Set E). We find that we can define all potential prime numbers larger than three as a multiple of six (Set E), where we either subtract one to obtain a potentially prime value in Set D or add one to obtain a potentially prime value in Set F.

We can then look at how frequently primes appear in these columns. When both the Set D and Set F values in the same row are prime, these are what mathematicians call twin primes. Whenever Set F in one row is prime and is followed by another prime in Set D in the next row, that's what mathematicians call couple primes. And whenever prime numbers appear next to each other in the same column, either in Set D or in Set F, mathematicians call "sexy" primes.

That last kind of prime is actually a bad mathematical pun. You'll notice that the minimum difference between any two sexy primes is six. In Greek, the word for six is εχι. If you're the kind of mathematician who slurs their words after consuming certain beverages, you might say that the Greek word for six issexi....

Unfortunately, not every value in the Set D and Set F columns are prime numbers. Some are composite numbers, which is to say they are found by multiplying prime numbers together, and even they have a pattern. If you multiply two primes from Set D together, you'll find their product in the Set F column. That's also true if you multiply two primes from Set F together.

But if you multiply a prime from Set D with a prime from Set F, you'll only find the resulting composite product in the Set D column.

These are far from the only patterns going on with the distribution of prime numbers. Back in 1963, Stanislaw Ulam found that when he wrote numbers out in a spiral order on a square grid, the prime numbers would appear in diagonal patterns.

The Coding Train's Daniel Shiffman explains how to generate Ulam's Spiral and develops code to generate it in the following 24 minute video:

The Ulam (or Prime) Spiral forms when numbers are written in order in a spiral pattern on square grid paper, but since we already know that the distribution of primes is linked to multiples of six, what would we find if we repeated that exercise using a hexagonal grid?

The following image illustrates some new patterns that emerge in a hexagonal spiral. Just for fun, we've indicated the prime numbers with boldface font and have colored the hexagons that correspond to Set D and Set F in our original table and have used red lines to connect the twin primes:

Hexgrid number spiral with primes highlighted and twin primes connected

Using a hexagonal grid like this, additional relationships can be identified to map out where prime numbers may occur. In practice, that means we can break the Set D and Set F values into subsets that can be independently explored. In 2011, Dmitri Tishchenko mapped 90,000 numbers onto a hexagon grid like this, which gives some tantalizing hints at the underlying structure of primes. He had left the task of visualizing the Set D (6n-1) and Set F (6n+1) on the grid for a future project, which is what inspired us to create our hexgrid chart.

Then again, if you really want to things to the next level, you could write out the numbers using polar coordinates on an Archimedian spiral. The patterns that arise when you do that leads to a whole different story for another long holiday weekend.


José William Porras Ferreira. The Pattern of Prime Numbers. Applied Mathematics, Vol. 8, No. 2. DOI: 10.4236/am.2017.82015. [PDF Document]. February 2017.

Image credit: Primes vs Composites by David Eppstein via Wikimedia Commons. Creative Commons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.

Notes: We've released the Basic Patterns of Primes image, which is freely available via Wikimedia Commons under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Labels: , ,

About Political Calculations

Welcome to the blogosphere's toolchest! Here, unlike other blogs dedicated to analyzing current events, we create easy-to-use, simple tools to do the math related to them so you can get in on the action too! If you would like to learn more about these tools, or if you would like to contribute ideas to develop for this blog, please e-mail us at:

ironman at politicalcalculations

Thanks in advance!

Recent Posts

Indices, Futures, and Bonds

Closing values for previous trading day.

Most Popular Posts
Quick Index

Site Data

This site is primarily powered by:

This page is powered by Blogger. Isn't yours?

CSS Validation

Valid CSS!

RSS Site Feed

AddThis Feed Button


The tools on this site are built using JavaScript. If you would like to learn more, one of the best free resources on the web is available at W3Schools.com.

Other Cool Resources

Blog Roll

Market Links

Useful Election Data
Charities We Support
Shopping Guides
Recommended Reading
Recently Shopped

Seeking Alpha Certified