← All projects / 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.
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.
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.
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
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.
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.
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".
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.
Adding 6 is adding 110 in binary. Here are the first few of each kind, with their bits lined up.
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.
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.
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.
| Family | How it's built | Remainders by 6, one loop | Rows that are 6n + 1 | Rows that are 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.
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.
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.
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 used | Pattern length | Marks that are 1 | Numbers left | The pattern as a family |
|---|
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.
| Up to | Numbers that are 6n ± 1 | Primes among them | Share | Primes that are 6n + 1 | Primes that are 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.