← All projects / Which Primes Split, Read in Base 3

Which primes split, read in base 3

On Change the Carry, splitting the carry makes a number system built on √13, and an ordinary prime splits there when its remainder on dividing by 13 is 1, 3, 4, 9, 10 or 12. You can read that straight off the prime's base 3 digits. Cut them into blocks of three, add the blocks up, and the prime splits exactly when the block that's left is made of nothing but 0s and 1s.

Fold a number

Type any whole number. Here are its base 3 digits cut into blocks of three from the right, the blocks added, and the same again until one block is left.

All thirteen remainders

The block that's left is the number's remainder on dividing by 13, written in base 3. The six remainders where a prime splits are exactly the blocks made of 0s and 1s. In base 3 without a zero (digits 1, 2, 3) they are the blocks made of 1s and 2s.

The primes up to 300

block of 0s and 1s: splitsblock with a 2: stays prime13 itself

Touch a prime for its folded block.

Why it works

13 is 111 in base 3

27 is one more than 26, which is twice 13. So every block of three base 3 digits is worth the same, mod 13, wherever it sits. Adding the blocks keeps the remainder. It's casting out nines, done in base 3 with 13 in place of 9.

The six remainders are powers of 3, plus or minus

1, 3 and 9 are the powers of 3 mod 13 (27 comes back to 1). Their negatives are 12, 10 and 4. In base 3 the powers are 001, 010 and 100, and the negatives are 110, 101 and 011: a single 1, or a single 0.

And those are the squares mod 13

Whether a prime splits depends on whether 13 is a square mod that prime. Gauss's law of quadratic reciprocity turns that round: it's whether the prime is a square mod 13. The squares mod 13 are 1, 3, 4, 9, 10 and 12, the same six.

Checked on every prime to 2 million

All 148,930 primes from 5 to 2,000,000 (13 left out): the folding gives the right remainder, and "a block of 0s and 1s" agrees with splitting for every one. The zero-free version agrees too. The smallest two follow the same rule: 3 folds to 010 and splits, 2 folds to 002 and doesn't.

The ingredients are old: repunits and divisibility tests, and quadratic reciprocity (Gauss, 1801). The neat part is that for 13, which is a repunit in base 3, the answer comes out as a digit pattern.