Prime triples and the Sieve of Eratosthenes

For the last week I’ve been looking at the last digits of triples of consecutive prime numbers. This exercise was inspired by the new paper of by Robert J. Lemke Oliver and Kannan Soundararajan of Stanford who just made some surprising discoveries about last digits of pairs of consecutive primes. I wrote about my week-long project here:

My fun interaction with prime numbers this week

One of the strange patterns that I noticed was that each of the 64 last digit triples seems to have a partner that occurs with the same frequency. I did not know why this paring was happening and wrote to Lemke Oliver and Soundararajan to see if there was an explanation that I could understand.

They wrote back (yay!) and told me that the pairing related to something that occurs in the Sieve of Eratosthenes. The idea goes something like this:

(1) The pairing I was seeing was that the last digit triple (A,B,C) occurs with about the same frequency as the triple (-C,-B,-A). All of these last digits are being represented mod 10, so 3 = -7, 1 = -9, 7 = -3, and 9 = -1.

(2) Lemke Oliver and Soundararajan told me that you can see a similar groping in the Sieve of Erathosthenes at every step. So, if you stop after crossing out all the multiples of 2, 3, and 5 you’ll see the same number of consecutive last digits of the form, say,(7,1,3) as you’ll see of the form (7,9,3).

The reason has to do with properties of modular arithmetic – I think. I have to confess that I didn’t understand the full explanation (even though it only took 1 paragraph!), but it did seem like a fun idea to try to explore.

So, this morning I decided to explore the idea a little bit with my kids. I started by explaining the ideas about last digits of consecutive primes that caught my eye last week.

Then we worked out the first three steps of the Sieve of Eratosthenes and I asked the kids to talk about some of the patterns they saw:


Next we looked at some of the last digits in consecutive numbers which remained on the board. I also explained the (A,B,C) and (-C,-B,-A) pattern which led to a brief diversion into what -X means in mod 10.

Another fun question for kids in this part was – how many different triples of last digits of prime numbers are there?


The last thing we did was look to see if there were any (A,B,C) and (-C,-B,-A) pairs on the board. The e-mail from Lemke Oliver and Soundararajan said that there would be the same number of pairs in the numbers. Of course we only had the integers up to 60 on the board so I had no idea if we’d see any pairs. Turns out that we did – exciting!

It is fun to be able to find new math reserach that you can (partially) explain to kids 🙂


So, a fun little impromptu project for today. Sorry this one was a little rushed – the kids were heading out to go hiking in NH and I wanted to get in a short project before they left.

My fun interaction with prime numbers this week

Last week I saw a amazing new result about primes by two mathematicians at Stanford – Robert J. Lemke Oliver and Kanna Soundararajan – via an Evelyn Lamb article:

Peculiar Pattern found in “Random” Prime Numbers by Evelyn Lamb

Erica Klarreich at Quanta magazine also wrote a fantastic article about the result:

Mathematicians Discover Prime Conspiracy by Erica Klarreich

and there’s also a neat discussion of the result on Terry Tao’s blog:

Terry Tao’s blog post about the new result

After seeing the two articles (I only saw Tao’s blog post today) I thought it would be fun to play around with some similar ideas and chose to look at the last digits of triples of consecutive primes. Over the course of the week I was able to use a simple program in Mathematica to count how often the different triples of last digits occur in consecutive primes in the first 10 billion primes. Right from the start I found something I didn’t expect – counting the occurrence of the triples of last digits seemed to pair the sets of last digits quite naturally into groups of 2.

For example, for 3 consecutive primes in the first 10 billion prime numbers the last digits (3,7,1) occur 178,500,881 times and the last digits (9,3,7) occur 178,500,928 times. Another example of the strange grouping is that the triple (1,1,3) occurs 147,750,170 times and the triple (7,9,9) occurs 147,761,746 times. Weird – what’s causing this clustering?

All of my data is in the google doc linked below. I’m sorry that the data in the google doc isn’t organized very well – I was just playing around for myself, but thought that it might be fun to share anyway:

My google doc with all of the data I collected this week

I didn’t really study any number theory in college or graduate school, so I have essentially no way to know if something like the counts for the last digits of consecutive prime triples pairing up is an easy to prove fact or an impossible to prove fact. After thinking about the strange groups of two for a few days without having any decent ideas I sent an e-mail to authors of the new paper and asked them for help. They wrote back last night – which was super cool! – and provided a (possibly) easy way to think about it. I sort of can’t believe that they wrote back, but I’m really excited to spend a bit more time trying to understand their explanation.

Receiving their e-mail got me even more interested in / excited about their paper, so I spent several hours today going through it one more time. The results and conjectures are general enough to apply to the problem of consecutive triples and that led me to try to see if the paper could help me get a better understanding of the data I’d collected. Happily, I was able to understand a bit more of the paper the 2nd time through,

With sort of an “I know enough to be dangerous” understanding I attempted to predict the number of various prime triples in the next set of 1 billion primes (so, last digits of three consecutive primes from the 10 billionth prime number to the 11 billionth prime number). My guesses are in column R and column U of the “Approximations” tab in my google doc. The results should be in tomorrow morning 🙂

One fun thing about the two sets of guesses is that the sum of the guesses for all of the triples adds up to almost exactly 1 billion! Since I’m looking at 1 billion primes the sum be 1 billion, but I didn’t take that constraint into account (not directly anyway) when I was playing with the numbers.

One other bit of structure I was able to notice in the data after re-reading the paper today was a different set of clustering. The triples with three of the same numbers have the lowest counts, triples with two of the same number in a row have (generally) the next lowest counts, triples with two numbers that are the same, but not in a row have (generally) the next lowest counts, and triples with three different numbers have (generally) the highest counts. *I think* their paper predicts this ordering.

So, a really fun week of playing around with prime numbers. There are still a few things to think about – the e-mail from the paper’s authors, and seeing if there’s any way to improve the predictions – but I’m extremely happy with how this little side project went this week. Haven’t had that much fun learning new math in a long time 🙂