← All projects / Primes in the Families

Hunting primes in the families

A prime is a number nothing divides except 1 and itself. I listed every prime up to 100,000, then searched all eight binary families for primes, out to numbers 6,000 digits long.

Every prime up to 100,000

They thin out as you go

The first 10,000 numbers hold 1,229 primes. The last 10,000 hold 879.

Their last digits are nearly even

Past 5, a prime can only end in 1, 3, 7 or 9. Each gets close to a quarter. 2 and 5 are the only primes with their endings.

List
Write as
Download the full list (all four forms)

A 60-hour clock for the 67s and 97s

This is the strongest pattern in where these families' primes fall. A 67s number is a power of two plus 3. Count which power it is, and put that count on a clock with 60 hours. Most of the hours can never hold a prime, and every prime ever found sits on one of the others.

The 67s: 2 to some power, plus 3

The 97s: 3 times 2 to some power, plus 1

live hour, with how many known primes land on itdead hour, with the small prime that divides everything on it

The full lists of known primes, the clock written in base 60 and the odds for each live hour are on their own page.

proved

38 of the 60 hours are dead for ever

On a dead hour, every number divides by the same small prime: 5, 7, 11, 13 or 61. Take the 67s. Whenever the power leaves 1 after dividing by 4, the number divides by 5. That alone removes a quarter of the clock. Each small prime removes its own slice, on its own short cycle.

measured

Every known prime is on a live hour

measured

Even powers beat odd ones

measured

The forecast is about right

exact

What the clock can't do

It says where a prime can't be, and how many to expect among the hours left. It doesn't say which live hour gets the next one. On the live hours the primes land with no pattern I can find: I tested counting, registers, groups of two, three and four, and mirrored blocks on the order of the two families, and each one failed on fresh data.

The dead hours, seen in base 8

A base 8 digit is three bits. So a power of two is a 1, a 2 or a 4 followed by zeros, and a 67s number is that with a 3 on the end: 67 is 103, 131 is 203, 259 is 403. The front digit goes round 1, 2, 4 as the power climbs.

proved

Front digit 4 means a multiple of 7

In base 8, adding up the digits keeps the remainder by 7, the way adding digits in base 10 keeps the remainder by 9. A 67s number starting with 4 has digits adding to 4 + 3 = 7, so it divides by 7. That is every ÷7 box on the clock above, a third of all the hours. 259 is 403, and 259 is 7 × 37.

measured

Every known prime starts with 1 or 2

Of the 58 known 67s primes, 37 start with 1 in base 8 and 20 start with 2. The one left over is 7 itself, which is just the digit 7. The live hours split 13 to 9 the same way, which forecasts about 34 and 23, so the lean towards 1 is roughly what the clock predicts.

proved

The 97s do the same thing

A 97s number in base 8 starts 3, 6 or 14, then zeros, then a 1. Front digit 6 gives 6 + 1 = 7, so those are its ÷7 hours. 49 is 61 in base 8.

The other dead hours work the same way. Group the bits in a different size and look at the front digit.

Divides byGroup the bits inFront digit that kills itBecauseHours removed
7threes (base 8)44 + 3 = 71 in 3
5fours (base 16)22 + 3 = 51 in 4
11tens (base 1,024)88 + 3 = 111 in 10
13twelves (base 4,096)1,0241,024 + 3 = 1,027 = 13 × 791 in 12
61sixties236236 + 3 = 61 × 523 × 2,154,0131 in 60
proved

The family rules out its own later members

5, 7 and 11 are the first three 67s: 2 + 3, 4 + 3 and 8 + 3. Each one divides a whole lane of the numbers that come after it. The next members do it too, on longer cycles: 19 divides every 18th one from power 4, and 67 divides every 66th from power 6. None of the 58 known primes sits on a lane started by an earlier one.

proved

The whole clock in one line

Hour h is dead exactly when 2h + 3 shares a factor with 260 − 1. I ran that for all 60 hours and it gives the same 22 live hours as the boxes above.

This explains the dead hours completely. It doesn't pick out which live hour holds the next prime. Worked out by tools/clock_octal.py.

How many bits does each prime have?

Count the primes in order: 2 is the 1st, 3 is the 2nd, 229 is the 50th. The number of bits a prime needs can be read straight off its position, with no need to know the prime. I checked the first 100,000 primes, which run up to 1,299,709.

Look up any position

Exact up to position 2,874,398,515, the last prime with 36 bits. The prime itself is shown for the first 100,000.

exact

The primes sit in bands, one for each bit count

The 32nd to the 54th primes all have 8 bits, so the 50th does: it's 229, which is 11100101. The 55th to the 97th have 9 bits. The table below has every band. To find the bits for any position, find its band.

measured

Each band is a little under twice the one before

measured

A formula gets it right 99.4% of the time

Take the position n and work out n × (ln n + ln ln n − 1), where ln is the natural log button on a calculator. That lands close to the prime. Count its bits and you have the answer.

measured

A prime has 3 or 4 more bits than its position

exact

What this does and doesn't tell you

The bit count is just the size of the prime, and size is the part of the primes that is well understood: it was proved in 1896 that the nth prime is close to n × ln n. The count says how many bits. It says nothing about which bits, and the band edges themselves have no formula. They have to be counted.

BitsPositionsHow many primesTimes the band beforeSmallest and largest

Positions 1 and 2 are the primes 2 and 3, the only ones with 2 bits. The band edges come from counting the primes below each power of two, done by tools/prime_bits.py. The smallest and largest prime are shown where this page works them out itself, up to 21 bits.

The primes in base 3

Base 3 counts in threes, with only the digits 0, 1 and 2. The first primes read 2, 10, 12, 21, 102, 111, 122, 201, 212. Switch the list above to base 3 to see them all. Three patterns show up.

proved

Every prime past 2 has an odd number of 1s

In base 3 a number is odd exactly when it has an odd number of 1s, because a 2 adds an even amount and a 1 adds an odd amount. Every prime past 2 is odd, so every one of them has an odd count of 1s: 111 has three, 21 has one, 10121 has three.

proved

The digital root of every prime past 2 is 1

Add up the base 3 digits, then the digits of the answer, until one digit is left. For every prime past 2 that digit is 1. In base 3 the digital root only records odd or even, and odd comes to 1. Before the last step the digit sums are always odd too: 3, 5, 7, 9 and so on, most often 11. The bases page has the same count for other bases.

proved

The last digit is 1 or 2, split almost evenly

measured

Primes don't like to repeat their last digit

This is the real surprise, and it was only noticed in 2016. It fades slowly: I counted on to 10 million and repeats were still only 43%.

measured

Special shapes are rare

One prime, then the next

Next prime ends in 1Next prime ends in 2

Each pair of neighbouring primes past 3, sorted by their last digits in base 3. The two "switch" boxes are much fuller than the two "repeat" boxes.

The same digits, read as ordinary numbers

Take the base 3 digits of a prime and read them as a normal number instead: 102 as one hundred and two, not eleven. That gives a new list: 2, 10, 12, 21, 102, 111, 122, 201, 212. I ran it for every prime below a million.

PrimeIn base 3Read as a normal numberReading minus primeWhich isThe reading is
22207 × 0prime
3101077 × 1even
5121277 × 1even
72121147 × 23 × 7
11102102917 × 13even
13111111987 × 143 × 37
171221221057 × 15even
192012011827 × 263 × 67
232122121897 × 27even
6721112,1112,0447 × 292prime
7922212,2212,1427 × 306prime
proved

The reading is always a multiple of 7 away from the prime

Each digit is worth a power of 3 in the prime and a power of 10 in the reading. 10 and 3 differ by 7, and so do their powers, up to a multiple of 7: 100 − 9 is 91, 1,000 − 27 is 973. So the reading and the prime leave the same remainder when divided by 7. It held for all 78,498 primes below a million.

proved

So the reading is never a multiple of 7

A prime isn't a multiple of 7, so its reading isn't either. The one exception is 7 itself, which reads 21. The same trick works for any two bases: write in one, read in the other, and the remainder by the gap between them survives.

proved

Half the readings are even

Past 3, the reading ends in 1 or 2, the prime's last base 3 digit. So it's even exactly when the prime is 2 more than a multiple of 3, which is half the time (39,266 of them, against 39,231 odd). It never ends in 5, and past 2 its digits always add to an odd number.

measured

Some readings are prime, but no more than the 7 rule explains

5,301 of the readings are prime, starting 2, 2111 (from 67) and 2221 (from 79). Among odd readings that's 13.5%. Doing the same to non-primes gives 10.8%, and 13.3% once the multiples of 7 are taken out. The gap left over is small enough to be chance (about one time in five).

measured

Almost none are multiples of 11

Only 24 of 78,498. This one isn't about primes. It happens to any odd number, because the digits are all 0, 1 and 2 and the numbers are short. It wears off as they get longer.

The 7 rule is exact, but it only carries over what was already known: a prime isn't a multiple of 7. It doesn't say which numbers are prime. Worked out by tools/base3_as_base10.py.

The primes in base 8

Base 8 uses the digits 0 to 7, and 8 itself is written 10. The first primes read 2, 3, 5, 7, 13, 15, 21, 23, 27, 35, 37, 45, 51. Switch the list above to base 8 to see them all. Here the last digit turns out to say a lot about the prime.

What the last digit tells you

How manyTwo squares addedA square plus twice a squareA square minus twice a squareExample

Every prime past 2 up to 100,000, sorted by its last digit in base 8, and whether it can be made each of three ways out of square numbers. The table is counted in your browser.

known theorem

The last digit decides how a prime is built from squares

Primes ending in 1 can be made all three ways. Each of the others can be made exactly one way: 3 as a square plus twice a square, 5 as two squares added, 7 as a square minus twice a square. This goes back to Fermat in the 1600s and has been proved for all primes. The table shows it holding on every prime in the list.

proved

Only four endings, shared almost evenly

A prime past 2 is odd, so it can only end in 1, 3, 5 or 7. Up to 100,000 each ending gets about 2,400 primes.

measured

Primes don't like to repeat their last digit here either

exact

The record primes are a 1 or a 3, then all 7s

The biggest known primes are all a power of two minus 1. In base 8 those read 3, 7, 37, 177, 17777, 377777, 1777777. Past 7, it's always a 1 or a 3 followed by nothing but 7s.

proved

73 is the only prime that's one digit repeated

73 is 111 in base 8. No other prime, however large, is a single digit written over and over. Two 1s make 9, which is 3 times 3. A run of four or more 1s always splits into two factors. And a run of any other digit divides by that digit.

One prime, then the next

Next ends in 1Next ends in 3Next ends in 5Next ends in 7

Share of all neighbouring pairs of primes. If the endings were independent every box would be about 6.3%. The four boxes on the diagonal, where the ending repeats, are about half that.

Which of them are in a family?

Not many. The families grow fast, so each one only has a handful of numbers under 100,000. Between them the eight families hold 22 of the 9,592 primes.

FamilyNumbers up to 100,000Primes among themWhich ones

Underlined primes are happy primes. 3 and 7 turn up in several families, because several families start 1, 3, 7.

Twins across two families

The 1null1s are a power of two plus 1. The 67s are a power of two plus 3. On rows 3, 5 and 17 both are prime, which makes twin primes two apart: 5 and 7, 17 and 19, 65,537 and 65,539.

Three families give almost nothing

The 1010 and null1null families each contain a single prime, which is 2. The 111000s contain none at all. The 0101 family contains only 5.

The big search

Then I kept going past 100,000. I tested every number in every family up to 20,000 binary digits long, which is about 6,000 ordinary digits. That's 120,001 numbers. 83 different primes turned up. A few small ones, like 3 and 7, are in more than one family, so the table adds up to 90.

FamilyNumbers testedPrimes foundBiggest oneRows they're onIn the first 100,000 rows

A row is a number's place in its family: row 8 of the 67s is 131. The last column is the answer for the first 100,000 numbers of each family. I couldn't test that far myself, so it comes from proofs where there is one and from searches other people have published where there isn't.

Where they fall

inside my search (up to row 20,000)past my search, taken from published lists

Each mark along the top is ten times further on than the last. A filled dot doesn't mean I found something new: in the 97s, 67s and 1null1s every filled dot was already on a published list, and my search simply found the same ones. The rings are primes too far out for me to test, which other people found. For the 000111s I found the family itself in the published catalogue but no list of its primes, and I only searched to row 10,001.

My search matches the published ones

The 97s and 67s are shapes mathematicians have already searched. My 25 and 34 primes are exactly the ones on their lists, row for row, which is a good sign the search is sound.

Why I stopped at 20,000 binary digits

Testing gets slower fast as the numbers get longer. The 100,000th number in a one-bit family is 30,000 digits long, and by my estimate testing that far would take my PC a couple of days per family.

The big ones aren't formally proved

Anything up to 2 million was checked for certain. The bigger primes passed the standard tests that a number which isn't prime fails almost every time. That's the usual standard for a search like this, but it isn't a proof.

The gaps between them

Take the rows where each family has a prime and measure how many rows it is from one to the next. Each dot below is one prime: how far along it is, against how long the wait was for the next one. The dashed line is where the wait equals the row, which would mean the next prime doesn't come until the row number has doubled.

Both scales are squeezed, so each mark is ten times the one before. Up the side is the gap to the next prime, in rows.

FamilyPrimesTypical jumpNext one before the row doublesLongest waitEvery gap, in order

Typical jump is the middle value of "next prime row divided by this prime row". The 97s and 67s include the published rows up to 100,000. The 000111s stop at row 10,001.

measured

The gaps grow with the row

Early on the primes are a row or two apart. By row 1,000 they're hundreds apart, and by row 10,000 they're thousands apart. The wait keeps pace with how far along you are: the next prime row is typically about 1.2 times the current one, and it nearly always turns up before the row number doubles.

exact

Half the rows can never hold one

In the 67s, every row that's 2 more than a multiple of 4 ends in 5, and every row that's a multiple of 3 divides by 7. In the 97s it's rows 1 more than a multiple of 4, and again every third row. Either way that rules out exactly half the rows, so the gaps can only land on the other half. In the 000111s every third row is a multiple of 7.

exact

The 1null1s have the one perfect pattern

Their primes are on rows 2, 3, 5, 9 and 17, so the gaps are 1, 2, 4, 8. Each gap is double the last. Then it stops: the next three places it could continue, rows 33, 65 and 129, have all been shown not to be prime.

measured

Past that, the sizes look random

Inside the allowed rows I couldn't find a rule for how big the next gap is. Short and long waits are mixed together, and the spread is about as big as the average, which is what waiting for a random event looks like. The longest wait is in the 97s: nothing between row 59,975 and row 80,192.

Is there a function for the gaps?

I checked three ways. There's a rule for the average gap, and it works. There's no formula for the individual gaps, and they pass the tests for being random.

FamilyRule for a typical gapRowsPrimes the rule predictsPrimes found
67sthe row divided by 3.620 to 100,00030.635
97sthe row divided by 3.620 to 100,00030.727
000111sthe row divided by 2.320 to 10,00114.315
measured

A rule for the average: yes

At row 3,600 of the 67s, expect to wait about 1,000 rows for the next prime. Put another way, every time the rows multiply by 10, expect about 8 more primes in the 67s and 97s, and about 5 in the 000111s. The 3.6 isn't fitted to the primes. It comes from counting how many rows survive division by every prime under 2 million, which measures how much likelier a family number is to be prime than an ordinary number its size.

measured

A formula for each gap: no

The best smooth curve through the prime rows looks close on a chart but misses the real rows by a factor of 1.4 to 1.9 on average, and by up to 3.7. Fitted on the first half of the 67s and asked for the second half, it's out by a factor of 8.

measured

The gaps behave like random waits

If primes turned up by chance at the rate the rule gives, the gaps would have a particular spread, and one gap would tell you nothing about the next. Both held in every family I tested. With only 14 to 34 gaps per family, that can't rule out a faint pattern, but nothing showed.

not proved

Nobody has proved any of this

Mathematicians expect families like these to behave randomly in exactly this way. But nobody has proved it, or even proved that the 67s or the 97s go on producing primes for ever.

The check is tools/gap_check.py in this site's code.

Is there a predictable pattern?

Partly. You can predict where primes can't be, and roughly how many to expect. Nobody knows a rule for exactly where the next one lands.

How many to expect

Count the primes in each tenfold stretch of rows. The stretches get ten times longer, but the count stays in the same range.

FamilyRows 1 to 1011 to 100101 to 1,0001,001 to 10,00010,001 to 100,000

That's what you'd expect if primes thin out in step with how long the numbers are. Each row is one bit longer than the last, so the chance of a prime keeps falling, and a stretch ten times longer makes up for it. With counts this small it's a rough fit, not a law: the 67s swing between 3 and 14.

Where primes can't be

exact

Even families have one prime at most

2 is the only even prime. The 1010 and null1null families both contain 2 and nothing else. The 111000s start at 8, so they have none.

exact

Every 0101 number splits in two

A 0101 number is always the number just below a power of two, times the number just above it, divided by 3. 85 is 15 × 17 ÷ 3, which leaves 5 × 17. 341 is 31 × 33 ÷ 3, which leaves 31 × 11. Only 5 escapes, because 3 × 5 ÷ 3 leaves 5 on its own.

exact

The 1null1s need a power-of-two gap

A power of two plus 1 can only be prime when the power is itself a power of two. That leaves rows 2, 3, 5, 9, 17, 33, 65 and so on. The first five give 3, 5, 17, 257 and 65,537. Every later one that's been checked, row 33 included, has turned out not to be prime.

exact

Every fourth number ends in 5

The 97s, 67s and 1null1s each end in 5 once every four rows, and anything bigger than 5 that ends in 5 divides by 5. That's a quarter of each family ruled out by the last digit alone. In the 000111s it's one in six.

exact

Small primes strike on a beat

In the 67s, 7 divides every third row and 11 divides every tenth. Every small prime has a beat like that, or never divides the family at all: 3 never divides a 97 or a 67 past the start. In the 1null1s it divides every second row.

exact

The 67s' prime rows stay on the doubling loop

Take the row numbers where the 67s have a prime and work out their digital roots. Past row 3 they are only ever 1, 2, 4, 5, 7 or 8, never 3, 6 or 9. That's because every row that's a multiple of 3 divides by 7. Two more rows are ruled out the same way: every row 11 past a multiple of 12 divides by 13, and every row 5 past a multiple of 18 divides by 19, which is why a root of 5 is rare.

exact

The 000111s' prime rows only have four digital roots

Past row 3, a prime row in the 000111s always has a digital root of 1, 4, 5 or 8. Rows with a root of 3, 6 or 9 belong to the thread that starts at 7, and everything in it divides by 7. Rows with a root of 2 or 7 always divide by 3. Roots 1 and 4 are the thread that starts at 1, and roots 5 and 8 are the thread that starts at 3.

measured

One thread of the 000111s is oddly quiet

Past row 40 and up to row 30,000, the thread that starts at 3 has 14 primes and the thread that starts at 1 has just one, on row 469. The divisibility rules say they should have about 8 and 7.

I checked it four ways. A second program built differently found the same primes. Sieving both threads with every prime under 20 million showed no hidden bias. No factoring trick splits the quiet thread's numbers. And sister sequences of the same shape had as many primes as expected. Nothing explains it.

Update: I ran the same search on every block size from 1 to 8, and 16. Across 29 threads the spread of primes is what chance gives, and a few other threads are lopsided too. That makes luck the likelier answer. The table is on the 000111s page.

On its own, a gap like the quiet thread's is about a 1 in 160 fluke. Allowing for the twenty or so sequences on this site, finding one this lopsided somewhere is nearer 1 in 9. So it could still be chance, but it's the most interesting open question here.

measured

Most numbers fall to a small prime

Only 1,934 of the 20,000 numbers in the 97s got past every prime under 2 million, and just 17 of those turned out to be prime. The 67s were almost the same: 1,927 got through and 24 were prime.

Happy primes, 313 and 131

Take a number, square each digit and add them up. Keep doing it. A happy number ends up at 1. Every other number falls into the same loop: 4, 16, 37, 58, 89, 145, 42, 20 and back to 4.

313 is a happy prime

313 goes to 19, then 82, 68, 100 and 1. It also reads the same backwards in ordinary digits and in binary, where it's 100111001. It isn't in any of the eight families.

131 is in the 67s, and it isn't happy

131 is row 8 of the 67s: 10000011. It's prime, it reads the same backwards, and every way of arranging its digits is prime too: 113, 131 and 311. But it goes 131, 11, 2, 4 and then round the loop for good.

Seven happy primes in the families

Of the 22 family primes under 100,000, seven are happy: 7, 13, 19, 97, 193, 12,743 and 65,539. There are 1,465 happy primes under 100,000 altogether.