← All projects / Carryless Base 3

Base 3, with the carries dropped

Writing a number differently never changes which numbers are prime. Changing how multiplication works does. Take base 3 without a zero, multiply the school way, and throw the carries away: the result is a number system with primes of its own.

Base 3 without a zero

Use the digits 1, 2 and 3. After 3 comes 11, then 12, 13, 21. When a digit would go past 3 it wraps back to 1 and carries one, as in base 13 without a zero. With the ordinary carry, this is just another way of writing the counting numbers, and its primes are the ordinary primes.

DecimalNo-zero base 3DecimalNo-zero base 3DecimalNo-zero base 3

Drop the carries

Multiply 12 by 12 (that is, 5 by 5). The column totals are 1, 4, 4.

      1 2
    × 1 2
    -----
      2 4      12 × 2
    1 2        12 × 1, shifted
    -----
    1 4 4      column totals

  carry them:  2 2 1  = 25   (5 × 5, as usual)
  drop them:   1 1 1  = 13   (each 4 wraps to 1)
exact

13 stops being prime

13 is 111 in base 3, and carryless it is 12 ⊗ 12. The ordinary prime 13 splits into 5 ⊗ 5.

exact

3 turns into a zero

Anything times 3 wraps to 3, and adding 3 changes nothing. The zero that was removed from the digits comes back the moment the carries go. A number that starts with 3 is a shorter number with a leading zero: 311 is just 11.

exact

2 × 2 = 1

4 wraps to 1, so 2 behaves like −1. Swap every 1 and 2 in a number and you get its mirror twin, which factors the same way. 11 and 22 are twins; so are 12 and 21.

Multiply both ways

⊗

Primes of its own

A carryless prime is a number that can't be written as a carryless product of two shorter numbers. One-digit numbers don't count: 1 and 2 act like 1 and −1, and 3 is the zero.

DigitsCarryless primesMirror pairs
proved

Factoring is unique

Every number splits into carryless primes in exactly one way, apart from the mirror swap. Carryless base 3 is arithmetic on polynomials whose coefficients wrap at 3, and its primes are the irreducible polynomials.

proved

The counts are exact

Nobody can say how many ordinary primes have 10 digits without finding them. Here there is a formula (Gauss's count of irreducible polynomials), and the table above matches it. Even the Riemann hypothesis has a carryless version, and that one was proved decades ago.

exact

Is it a prime?

Building the table…

An exact formula

Ordinary primes have no formula that hands you the nth one without a search, and the simple estimates drift. Carryless primes come with exact tools. Put together, they give every carryless prime with no error at all.

proved

1. Every length is counted exactly

The number of carryless primes with L digits is 2 × I(L − 1), where I(d) = (3d minus the corrections for each divisor of d) ÷ d. For a prime d it is simply (3d − 3) ÷ d. This is Gauss's count of irreducible polynomials.

proved

2. Each length multiplies out to 1s and 3s

Multiply together every carryless prime of one length that starts with 1 (one of each mirror pair). The answer is always written in nothing but 1s and 3s. When the length is one more than a prime d, it is 1313…131 with (3d − 1) ÷ 2 ones.

proved

3. An exact test

A number of that length that starts with 1 is a carryless prime exactly when it carryless-divides that 1s-and-3s number. No composite gets through, unlike the Fermat test for ordinary primes, which 341, 561 and 76 more composites below 100,000 fool. For 3 and 4 digits the test is a digit rule: the last digit is not 3, and neither the digit sum nor the alternating digit sum is a multiple of 3.

DigitsPrimes starting with 1Their carryless productChecked

4. The nth carryless prime, exactly

  1. Add up the exact counts to find the length L of the nth prime, and its place r among the primes of that length.
  2. Count through the L-digit numbers that start with 1 or 2, in order.
  3. The r-th one that passes the exact test is the nth carryless prime.

5. A formula that makes them, with no testing

Steps 3 and 4 still test numbers one by one. This step doesn't test anything. For each length, fix one carryless prime m (the table below gives one for every length up to 11 digits) and call a root of it α. Then:

  1. Take a Lyndon word of length d = digits − 1: a string of 0s, 1s and 2s that is smaller than every rotation of itself (for d = 3: 001, 002, 011, 012, 021, 022, 112, 122).
  2. Read it in base 3 as a number k.
  3. The carryless prime is the number whose roots are αk, α3k, α9k, … (d of them, tripling the power each time).

Every Lyndon word gives a different prime, and together they give every carryless prime of that length that starts with 1. Swap the 1s and 2s to get the other half. The two-digit primes are 11, 12 and 13. To plug in n: find L and r from the counts, take the r-th Lyndon word of length L − 1 (or, if r is past the halfway point, the one that many places into the second half, then swap 1s and 2s).

DigitsFixed prime mLyndon wordsPrimes madeEvery prime of that length, once

Find the nth carryless prime

Building the table…

A quick estimate

Skip the test in step 3 and assume the primes of each length are spread evenly over their block: the nth is about s + (r − ½) ÷ i × 3L−1, where s is the first L-digit number and i the number of primes per half-block (start the second half one block later). Past n = 10,000 it lands about 0.02% away, about 35 numbers. The usual estimate for ordinary primes, n(ln n + ln ln n − 1), is about 0.4% away there. Carryless primes really are spread that evenly, which is the proved carryless Riemann hypothesis at work.

Against the ordinary primes

213173also an ordinary prime 21122carryless only

Rules in the carryless-only primes

Take the carryless primes that are not ordinary primes, one from each mirror pair, and compare them with every other composite number that starts with 1.

PropertyCarryless-only primesOther composites
proved

Never a multiple of 3

Apart from 13 and 23 themselves (6 and 9), a carryless prime never ends in 3, because ending in 3 means 13 is a carryless factor. A number that doesn't end in 3 is never a multiple of 3.

proved

Multiples of 4 half as often

Since 3 is one less than 4, a number's remainder by 4 comes from its alternating digit sum. For a carryless prime that sum can never be a multiple of 3, which rules out its most common value, 0, and with it half the multiples of 4.

measured

Otherwise the bits look like any others

Strings of ones

11…1 with k ones is a carryless prime exactly when k is prime and the powers of 3 go through every remainder on dividing by k.

OnesValueCarryless primeRule saysOrdinary prime

Looking for a pattern in the gaps

The numbers that are prime both ways start 5, 7, 17, 19, 29, 41 … and the first gaps two apart repeat: 17 − 5, 19 − 7 and 29 − 17 are all 12. The run ends at the next pair (41 − 19 = 22). Tested across all of them against random samples of ordinary primes the same size:

TestPrime both waysRandom ordinary primes

Both sit inside the random range. Membership needs two things, being a carryless prime and being an ordinary prime. The first has a fast exact test; nothing in the carryless world predicts the second.

Prime grids

Numbers run left to right, then down, from 1 in the top left. A lit cell is a number in the chosen set. At 13 wide each column holds one remainder by 13; at 12 wide the ordinary primes line up in four columns; at 27 wide the base 3 structure of the carryless primes shows.

Building…
Building…

Touch a cell for its number.

Flip results: the nth number that is prime both ways, with its low bits flipped by the nth piece of the stack 0, 1, 10, 010, 1010, …. The results are prime about as often as random odd numbers.

Base 13 works, base 12 breaks

Carryless base 3Carryless base 13Carryless base 12
exact

Base 13: the same, bigger

exact

Base 12: two worlds glued together

12 = 4 × 3, so a carryless base 12 number is secretly a wrap-at-4 number and a wrap-at-3 number at once. 3 ⊗ 4 = C, the zero. The ordinary prime 73 (written 61) acts like 1, because 61 ⊗ 61 = 1. And 300 (1CC) is 1C ⊗ 1C and also 16 ⊗ 16.

proved

The base has to be prime

Dropping the carries gives clean primes and unique factoring exactly when the base is prime: 2, 3, 5, 7, 11, 13. With the ordinary carry every base is fine and gives the ordinary primes.

Other carry rules

A carry rule says what 3 in one column is worth somewhere else. The rules that keep arithmetic working each quietly pick a number system.

Carry ruleWhat it really isPrimes
3 carries as 1 into the next columnordinary whole numbersthe ordinary primes
3 carries as −1base −3the same primes, spelled differently
3 carries as 2base 3/2, numbers with halvesalmost the same: only 2 stops being prime
Drop the carriespolynomials that wrap at 3a new set, this page
3 carries as 1 two columns overnumbers a + b√3about half the primes split: which ones

A carry rule picked at random usually breaks arithmetic itself (a × b stops matching b × a), and then "prime" stops meaning anything.

What it does and doesn't do

A clean world with its own primes

Unique factoring, exact counts, fast tests. Carryless multiplication in base 2 runs inside checksums and web encryption, and processors have an instruction for it.

Not a way to find ordinary primes

Only 13% of ordinary primes are carryless primes, and carryless primes are only a little more likely than average to be ordinary primes. All of that boost comes from skipping multiples of 3. Carrying is exactly what makes the ordinary primes hard.