Kannan Soundararajan and Robert Lemke Oliver of Stanford University published a paper recently that is leaving mathematicians scratching their heads. Their work exposed a mathematical bias of prime numbers in which a prime repels other would-be primes that end in the same digit. The researchers found some digits are ‘preferred’ in the detriment of others with various predilections. For instance, a prime ending in 9 is 65 percent likelier to be followed by a prime ending in 1 than one ending in 9.

“We’ve been studying primes for a long time, and no one spotted this before,” said Andrew Granville, a number theorist at the University of Montreal and University College London. “It’s crazy.”

It’s crazy because it’s one of those things everyone thought was written in stone: primes behave randomly. We should have known better, though, since primes *aren’t *random and follow a very deterministic path instead.

A prime is any number that’s only divisible by itself and the number one. These are 2, 3, 5, 7, 13 and so on. Twelve is not a prime because it’s divisible by 3 and 2, which are other primes. As you work up the ladder primes become increasingly hard to find. The largest prime found so far is 2^{74,207,281}-1 or 2 multiplied by itself more than 74 million times. That’s in the astronomical realm.

Except for the prime numbers 2 and 5, all other primes end in 1, 3, 7 or 9. You’d think that a prime has an equal chance of ending in any of the four, but apparently this is not the case.

Oliver and Soundararajan were inspired to make this research after attending a lecture by Tadashi Tokieda, of the University of Cambridge. Tokieda mentioned in passing a fun tidbit of coin-tossing: if Alice tosses a coin until she sees a head followed by a tail, and Bob tosses a coin until he sees two heads in a row, then on average, Alice will require four tosses while Bob will require six tosses. This is counter-intuitive because there’s a 50/50 chance any of the two faces showing for any toss. The two mathematicians wondered if any of this spooky action might be found in primes, which are ever mysterious.

The researchers first looked at prime number written in base 3 since it’s a lot easier to spot patterns. In base 3, primes end in either 1 or 2. For primes smaller than 1,000 a prime ending in 1 is more than twice as likely to be followed by a prime ending 2 than another prime ending in 1. The reverse holds true, with primes ending in 2 being much likelier to be followed by those ending in 1. They then looked at the first 400 billion primes and the same predisposition was confirmed. Whether it was base 3, 10 or any other variations, primes seem to have a knack of being followed by another ending in a different digit.

The mathematicians have no explanation yet. It’s not clear either if these ‘random’ behaviour is isolated or tied to other mathematical structures. For sure, others will investigate and who knows what other oddities we’ll learn about primes.