← All projects / 6n ± 1 in Binary

6n ± 1, in binary

Every prime past 3 is one more or one less than a multiple of 6. This page looks for the binary pattern behind that rule. There is one, and it's short. What it can't do is tell the primes from the other numbers of the same shape.

What the rule says

proved

Every prime past 3 is 6n + 1 or 6n − 1

Count in sixes and every number is 6n, 6n + 1, 6n + 2, 6n + 3, 6n + 4 or 6n + 5. Three of those are even and 6n + 3 is a multiple of 3. That leaves 6n + 1 and 6n + 5, and 6n + 5 is the same as one less than the next multiple of 6.

proved

It doesn't work backwards

25 is 6 × 4 + 1 and it's 5 × 5. 35 is 6 × 6 − 1 and it's 5 × 7. The rule only says a number isn't a multiple of 2 or 3. It says nothing about 5, 7, 11 or anything bigger.

measured

How much it narrows things

The pattern along the number line

Mark every number with a 1 if it is 6n ± 1 and a 0 if it isn't. Starting from 1 the marks go 1 0 0 0 1 0, and then the same six again, for ever.

6n ± 1and prime

exact

The pattern is the six bits 100010

exact

It's one of the quiet families

The pattern inside one number

proved

In binary: drop the last 1 and look at what's left

A number of either kind is odd, so its last bit is 1. Take that bit off. If what's left is a multiple of 3, the number is 6n + 1. If what's left is one short of a multiple of 3, the number is 6n − 1. If it's one over, the number is a multiple of 3.

proved

Multiples of 3 in binary

Number the bits from the right. Add up the bits in the odd places, and take away the bits in the even places. The number is a multiple of 3 exactly when the answer is. It works because 2 is one less than 3, the same way the alternating-digits test for 11 works in base 10.

proved

Base 4 makes it plain adding

Pair the bits up and you have base 4. There the test is the one people know for 3 and 9 in base 10: add the digits. The number and its base 4 digit sum leave the same remainder when divided by 3. So 6n + 1 is "odd, and the base 4 digits add to one more than a multiple of 3".

proved

Base 8 alternates again

8 is one less than 9, so in base 8 it's back to adding and taking away digits in turn. A number of either kind ends in 1, 3, 5 or 7 in base 8, and its alternating digit sum isn't a multiple of 3.

Counting up in sixes

Adding 6 is adding 110 in binary. Here are the first few of each kind, with their bits lined up.

6n − 1

6n + 1

exact

Every column repeats

The last bit is always 1. The next one flips every row. The one after repeats every 4 rows, the next every 8, and so on, doubling each time. So any fixed number of final bits is a pattern you could write down once and reuse. The trouble is that the pattern never stops getting longer as you go left.

exact

6n + 1 is "3n, then a 1"

6n is 3n with a 0 on the end, so 6n + 1 is the bits of 3n with a 1 on the end. And 6n − 1 is the bits of 3n − 1 with a 1 on the end. That's the drop-the-last-bit rule read forwards.

The site's families on the wheel

Take any family from the other pages and ask of each row: is it 6n + 1, 6n − 1, or neither? The answers always come round in a loop.

FamilyHow it's builtRemainders by 6, one loopRows that are 6n + 1Rows that are 6n − 1
proved

Every 67s number is 6n ± 1

A power of two leaves 2 or 4 when divided by 6, turn about. Add 3 and you get 5 or 1. So the 67s go 6n − 1, 6n + 1, 6n − 1, 6n + 1 without a single miss. None of them is ever a multiple of 2 or 3.

proved

Every 97s number is 6n + 1

Three times a power of two is a multiple of 6, and the 97s add 1 to that. So all of them are 6n + 1 and none is 6n − 1. This is part of why both families are good places to look for primes: the wheel never rules any of their rows out. These two facts have a page of their own, with a picture and six questions that follow from them.

666 and the 107 in base 8

exact

666 is a multiple of 6

exact

107 in base 8 is 71, a 6n − 1 prime

exact

In base 8 the wheel is 42, not 107

The pattern 100010 splits into 100 and 010, which read 4 and 2. So the 6n ± 1 marks, written in base 8, are 42 42 42 for ever. Start one place along and it reads 21 21 21, or 50 50 50. The 07 pattern comes from three 0s and three 1s, which is a different repeat with the same length. They share the six-bit rhythm and nothing else.

Bigger wheels

6n ± 1 is the wheel for 2 and 3. Bring in 5 and the pattern is 30 marks long. Bring in 7 and it's 210.

Small primes usedPattern lengthMarks that are 1Numbers leftThe pattern as a family

proved

Each wheel is exact, and none of them finishes

Every wheel is a true binary pattern for "not a multiple of these small primes". But each new prime makes the pattern that many times longer and removes a smaller slice than the one before. No pattern of fixed length can pick out the primes, because a pattern that repeats every m numbers only knows about the primes that divide m.

measured

Only the wheel of 6 is a quiet family

How many are prime

Up toNumbers that are 6n ± 1Primes among themSharePrimes that are 6n + 1Primes that are 6n − 1
measured

The two kinds stay level, with 6n − 1 a nose in front

What this is, and what it isn't

There is a binary pattern for 6n ± 1

Three of them, in fact: the six marks 100010 along the number line, the drop-the-last-bit test inside a number, and the repeating columns when you count up in sixes. All three are exact.

It isn't a pattern for the primes

6n ± 1 is the sieve by 2 and 3 and nothing more. It keeps a third of all numbers, and fewer and fewer of those are prime as the numbers grow. The counters and the clock hit the same wall from other directions.