You Sixy Beast

666 is the Number of the Beast. But it’s much more than that. After all, it’s a number, so it has mathematical properties (everything has mathematical properties, but it’s a sine-qua-non of numbers). For example, 666 is a palindromic number, reading the same forwards and backwards. And it’s a repdigit, consisting of a single repeated digit. Now try answering this question: how many pebbles are there in this triangle?



••
•••
••••
•••••
••••••
•••••••
••••••••
•••••••••
••••••••••
•••••••••••
••••••••••••
•••••••••••••
••••••••••••••
•••••••••••••••
••••••••••••••••
•••••••••••••••••
••••••••••••••••••
•••••••••••••••••••
••••••••••••••••••••
•••••••••••••••••••••
••••••••••••••••••••••
•••••••••••••••••••••••
••••••••••••••••••••••••
•••••••••••••••••••••••••
••••••••••••••••••••••••••
•••••••••••••••••••••••••••
••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••••


Counting the pebbles one by one would take a long time, but there’s a short-cut. Each line of the triangle after the first is one pebble longer than the previous line. There are 36 lines and therefore 36 pebbles in the final line. So the full number of pebbles = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36. And there’s an easy formula for that sum: (36^2 + 36) / 2 = (1296 + 36) / 2 = 1332 / 2 = 666.

So 666 is the 36th triangular number:


1 = 1
1+2 = 3
1+2+3 = 6
1+2+3+4 = 10
1+2+3+4+5 = 15
1+2+3+4+5+6 = 21
1+2+3+4+5+6+7 = 28
1+2+3+4+5+6+7+8 = 36
1+2+3+4+5+6+7+8+9 = 45
1+2+3+4+5+6+7+8+9+10 = 55
[...]
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36 = 666

But what’s tri(666), the 666th triangular number? By the formula above, it equals (666^2 + 666) / 2 = (443556 + 666) / 2 = 444222 / 2 = 222111. But recall something else from above: tri(6) = 1+2+3+4+5+6 = 21. Is it a coincidence that tri(6) = 21 and tri(666) = 222111? No, it isn’t:


tri(6) = 21 = (6^2 + 6) / 2 = (36 + 6) / 2 = 42 / 2
tri(66) = 2211 = (66^2 + 66) / 2 = (4356 + 66) / 2 = 4422 / 2
tri(666) = 222111 = (666^2 + 666) / 2 = (443556 + 666) / 2 = 444222 / 2
tri(6666) = 22221111
tri(66666) = 2222211111
tri(666666) = 222222111111
tri(6666666) = 22222221111111
tri(66666666) = 2222222211111111
tri(666666666) = 222222222111111111
tri(6666666666) = 22222222221111111111
tri(66666666666) = 2222222222211111111111
tri(666666666666) = 222222222222111111111111
tri(6666666666666) = 22222222222221111111111111
tri(66666666666666) = 2222222222222211111111111111
tri(666666666666666) = 222222222222222111111111111111

So we’ve looked at tri(36) = 666 and tri(666) = 222111. Let’s go a step further: tri(222111) = 24666759216. So 666 appears again. And the sixiness carries on here:


tri(36) = 666
tri(3366) = 5666661
tri(333666) = 55666666611
tri(33336666) = 555666666666111
tri(3333366666) = 5555666666666661111
tri(333333666666) = 55555666666666666611111
tri(33333336666666) = 555555666666666666666111111
tri(3333333366666666) = 5555555666666666666666661111111
tri(333333333666666666) = 55555555666666666666666666611111111
tri(33333333336666666666) = 555555555666666666666666666666111111111
tri(3333333333366666666666) = 5555555555666666666666666666666661111111111
tri(333333333333666666666666) = 55555555555666666666666666666666666611111111111
tri(33333333333336666666666666) = 555555555555666666666666666666666666666111111111111
tri(3333333333333366666666666666) = 5555555555555666666666666666666666666666661111111111111
tri(333333333333333666666666666666) = 55555555555555666666666666666666666666666666611111111111111

Root Pursuit

Roots are hard, powers are easy. For example, the square root of 2, or √2, is the mysterious and never-ending number that is equal to 2 when multiplied by itself:

• √2 = 1·414213562373095048801688724209698078569671875376948073...

It’s hard to calculate √2. But the powers of 2, or 2^p, are the straightforward numbers that you get by multiplying 2 repeatedly by itself. It’s easy to calculate 2^p:

• 2 = 2^1
• 4 = 2^2
• 8 = 2^3
• 16 = 2^4
• 32 = 2^5
• 64 = 2^6
• 128 = 2^7
• 256 = 2^8
• 512 = 2^9
• 1024 = 2^10
• 2048 = 2^11
• 4096 = 2^12
• 8192 = 2^13
• 16384 = 2^14
• 32768 = 2^15
• 65536 = 2^16
• 131072 = 2^17
• 262144 = 2^18
• 524288 = 2^19
• 1048576 = 2^20
[...]

But there is a way to find √2 by finding 2^p, as I discovered after I asked a simple question about 2^p and 3^p. What are the longest runs of matching digits at the beginning of each power?

131072 = 2^17
129140163 = 3^17
1255420347077336152767157884641... = 2^193
1214512980685298442335534165687... = 3^193
2175541218577478036232553294038... = 2^619
2177993962169082260270654106078... = 3^619
7524389324549354450012295667238... = 2^2016
7524012611682575322123383229826... = 3^2016

There’s no obvious pattern. Then I asked the same question about 2^p and 5^p. And an interesting pattern appeared:

32 = 2^5
3125 = 5^5
316912650057057350374175801344 = 2^98
3155443620884047221646914261131... = 5^98
3162535207926728411757739792483... = 2^1068
3162020133383977882730040274356... = 5^1068
3162266908803418110961625404267... = 2^127185
3162288411569894029343799063611... = 5^127185

The digits 31622 rang a bell. Isn’t that the start of √10? Yes, it is:

• √10 = 3·1622776601683793319988935444327185337195551393252168268575...

I wrote a fast machine-code program to find even longer runs of matching initial digits. Sure enough, the pattern continued:

• 316227... = 2^2728361
• 316227... = 5^2728361
• 3162277... = 2^15917834
• 3162277... = 5^15917834
• 31622776... = 2^73482154
• 31622776... = 5^73482154
• 3162277660... = 2^961700165
• 3162277660... = 5^961700165

But why are powers of 2 and 5 generating the digits of √10? If you’re good at math, that’s a trivial question about a trivial discovery. Here’s the answer: We use base ten and 10 = 2 * 5, 10^2 = 100 = 2^2 * 5^2 = 4 * 25, 10^3 = 1000 = 2^3 * 5^3 = 8 * 125, and so on. When the initial digits of 2^p and 5^p match, those matching digits must come from the digits of √10. Otherwise the product of 2^p * 5^p would be too large or too small. Here are the records for matching initial digits multiplied by themselves:

32 = 2^5
3125 = 5^5
• 3^2 = 9

316912650057057350374175801344 = 2^98
3155443620884047221646914261131... = 5^98
• 31^2 = 961

3162535207926728411757739792483... = 2^1068
3162020133383977882730040274356... = 5^1068
• 3162^2 = 9998244

3162266908803418110961625404267... = 2^127185
3162288411569894029343799063611... = 5^127185
• 31622^2 = 999950884

• 316227... = 2^2728361
• 316227... = 5^2728361
• 316227^2 = 99999515529

• 3162277... = 2^15917834
• 3162277... = 5^15917834
• 3162277^2 = 9999995824729

• 31622776... = 2^73482154
• 31622776... = 5^73482154
• 31622776^2 = 999999961946176

• 3162277660... = 2^961700165
• 3162277660... = 5^961700165
• 3162277660^2 = 9999999998935075600

The square of each matching run falls short of 10^p. And so when the digits of 2^p and 5^p stop matching, one power must fall below √10, as it were, and one must rise above:

3 162266908803418110961625404267... = 2^127185
3·162277660168379331998893544432... = √10
3 162288411569894029343799063611... = 5^127185

In this way, 2^p * 5^p = 10^p. And that’s why matching initial digits of 2^p and 5^p generate the digits of √10. The same thing, mutatis mutandis, happens in base 6 with 2^p and 3^p, because 6 = 2 * 3:

• 2.24103122055214532500432040411... = √6 (in base 6)

24 = 2^4
213 = 3^4
225522024 = 2^34 in base 6 = 2^22 in base 10
22225525003213 = 3^34 (3^22)
2241525132535231233233555114533... = 2^1303 (2^327)
2240133444421105112410441102423... = 3^1303 (3^327)
2241055222343212030022044325420... = 2^153251 (2^15007)
2241003215453455515322105001310... = 3^153251 (3^15007)
2241032233315203525544525150530... = 2^233204 (2^20164)
2241030204225410320250422435321... = 3^233204 (3^20164)
2241031334114245140003252435303... = 2^2110415 (2^102539)
2241031103430053425141014505442... = 3^2110415 (3^102539)

And in base 30, where 30 = 2 * 3 * 5, you can find the digits of √30 in three different ways, because 30 = 2 * 15 = 3 * 10 = 5 * 6:

• 5·E9F2LE6BBPBF0F52B7385PE6E5CLN... = √30 (in base 30)

55AA4 = 2^M in base 30 = 2^22 in base 10
5NO6CQN69C3Q0E1Q7F = F^M = 15^22
5E63NMOAO4JPQD6996F3HPLIMLIRL6F... = 2^K6 (2^606)
5ECQDMIOCIAIR0DGJ4O4H8EN10AQ2GR... = F^K6 (15^606)
5E9DTE7BO41HIQDDO0NB1MFNEE4QJRF... = 2^B14 (2^9934)
5E9G5SL7KBNKFLKSG89J9J9NT17KHHO... = F^B14 (15^9934)
[...]
5R4C9 = 3^E in base 30 = 3^14 in base 10
52CE6A3L3A = A^E = 10^14
5E6SOQE5II5A8IRCH9HFBGO7835KL8A = 3^3N (3^113)
5EC1BLQHNJLTGD00SLBEDQ73AH465E3... = A^3N (10^113)
5E9FI455MQI4KOJM0HSBP3GG6OL9T8P... = 3^EJH (3^13187)
5E9EH8N8D9TR1AH48MT7OR3MHAGFNFQ... = A^EJH (10^13187)
[...]
5OCNCNRAP = 5^I in base 30 = 5^18 in base 10
54NO22GI76 = 6^I (6^18)
5EG4RAMD1IGGHQ8QS2QR0S0EH09DK16... = 5^1M7 (5^1567)
5E2PG4Q2G63DOBIJ54E4O035Q9TEJGH... = 6^1M7 (6^1567)
5E96DB9T6TBIM1FCCK8A8J7IDRCTM71... = 5^F9G (5^13786)
5E9NM222PN9Q9TEFTJ94261NRBB8FCH... = 6^F9G (6^13786)
[...]

So that’s √10, √6 and √30. But I said at the beginning that you can find √2 by finding 2^p. How do you do that? By offsetting the powers, as it were. With 2^p and 5^p, you can find the digits of √10. With 2^(p+1) and 5^p, you can find the digits of √2 and √20, because 2^(p+1) * 5^p = 2 * 2^p * 5^p = 2 * 10^p:

•  √2 = 1·414213562373095048801688724209698078569671875376948073...
• √20 = 4·472135954999579392818347337462552470881236719223051448...

16 = 2^4
125 = 5^3
140737488355328 = 2^47
142108547152020037174224853515625 = 5^46
1413... = 2^243
1414... = 5^242
14141... = 2^6651
14142... = 5^6650
141421... = 2^35389
141420... = 5^35388
4472136... = 2^162574
4472135... = 5^162573
141421359... = 2^3216082
141421352... = 5^3216081
447213595... = 2^172530387
447213595... = 5^172530386
[...]

God Give Me Benf’

In “Wake the Snake”, I looked at the digits of powers of 2 and mentioned a fascinating mathematical phenomenon known as Benford’s law, which governs — in a not-yet-fully-explained way — the leading digits of a wide variety of natural and human statistics, from the lengths of rivers to the votes cast in elections. Benford’s law also governs a lot of mathematical data. It states, for example, that the first digit, d, of a power of 2 in base b (except b = 2, 4, 8, 16…) will occur with the frequency logb(1 + 1/d). In base 10, therefore, Benford’s law states that the digits 1..9 will occur with the following frequencies at the beginning of 2^p:

1: 30.102999%
2: 17.609125%
3: 12.493873%
4: 09.691001%
5: 07.918124%
6: 06.694678%
7: 05.799194%
8: 05.115252%
9: 04.575749%

Here’s a graph of the actual relative frequencies of 1..9 as the leading digit of 2^p (open images in a new window if they appear distorted):


And here’s a graph for the predicted frequencies of 1..9 as the leading digit of 2^p, as calculated by the log(1+1/d) of Benford’s law:


The two graphs agree very well. But Benford’s law applies to more than one leading digit. Here are actual and predicted graphs for the first two leading digits of 2^p, 10..99:



And actual and predicted graphs for the first three leading digits of 2^p, 100..999:



But you can represent the leading digit of 2^p in another way: using an adaptation of the famous Ulam spiral. Suppose powers of 2 are represented as a spiral of squares that begins like this, with 2^0 in the center, 2^1 to the right of center, 2^2 above 2^1, and so on:

←←←⮲
432↑
501↑
6789

If the digits of 2^p start with 1, fill the square in question; if the digits of 2^p don’t start with 1, leave the square empty. When you do this, you get this interesting pattern (the purple square at the very center represents 2^0):

Ulam-like power-spiral for 2^p where 1 is the leading digit


Here’s a higher-resolution power-spiral for 1 as the leading digit:

Power-spiral for 2^p, leading-digit = 1 (higher resolution)


And here, at higher resolution still, are power-spirals for all the possible leading digits of 2^p, 1..9 (some spirals look very similar, so you have to compare those ones carefully):

Power-spiral for 2^p, leading-digit = 1 (very high resolution)


Power-spiral for 2^p, leading-digit = 2


Power-spiral for 2^p, ld = 3


Power-spiral for 2^p, ld = 4


Power-spiral for 2^p, ld = 5


Power-spiral for 2^p, ld = 6


Power-spiral for 2^p, ld = 7


Power-spiral for 2^p, ld = 8


Power-spiral for 2^p, ld = 9


Power-spiral for 2^p, ld = 1..9 (animated)


Now try the power-spiral of 2^p, ld = 1, in some other bases:

Power-spiral for 2^p, leading-digit = 1, base = 9


Power-spiral for 2^p, ld = 1, b = 15


You can also try power-spirals for other n^p. Here’s 3^p:

Power-spiral for 3^p, ld = 1, b = 10


Power-spiral for 3^p, ld = 2, b = 10


Power-spiral for 3^p, ld = 1, b = 4


Power-spiral for 3^p, ld = 1, b = 7


Power-spiral for 3^p, ld = 1, b = 18


Elsewhere Other-Accessible…

Wake the Snake — an earlier look at the digits of 2^p

Wake the Snake

In my story “Kopfwurmkundalini”, I imagined the square root of 2 as an infinitely long worm or snake whose endlessly varying digit-segments contained all stories ever (and never) written:

• √2 = 1·414213562373095048801688724209698078569671875376948073…

But there’s another way to get all stories ever written from the number 2. You don’t look at the root(s) of 2, but at the powers of 2:

• 2 = 2^1 = 2
• 4 = 2^2 = 2*2
• 8 = 2^3 = 2*2*2
• 16 = 2^4 = 2*2*2*2
• 32 = 2^5 = 2*2*2*2*2
• 64 = 2^6 = 2*2*2*2*2*2
• 128 = 2^7 = 2*2*2*2*2*2*2
• 256 = 2^8 = 2*2*2*2*2*2*2*2
• 512 = 2^9 = 2*2*2*2*2*2*2*2*2
• 1024 = 2^10
• 2048 = 2^11
• 4096 = 2^12
• 8192 = 2^13
• 16384 = 2^14
• 32768 = 2^15
• 65536 = 2^16
• 131072 = 2^17
• 262144 = 2^18
• 524288 = 2^19
• 1048576 = 2^20
• 2097152 = 2^21
• 4194304 = 2^22
• 8388608 = 2^23
• 16777216 = 2^24
• 33554432 = 2^25
• 67108864 = 2^26
• 134217728 = 2^27
• 268435456 = 2^28
• 536870912 = 2^29
• 1073741824 = 2^30
[...]

The powers of 2 are like an ever-lengthening snake swimming across a pool. The snake has an endlessly mutating head and a rhythmically waving tail with a regular but ever-more complex wake. That is, the leading digits of 2^p don’t repeat but the trailing digits do. Look at the single final digit of 2^p, for example:

• 02 = 2^1
• 04 = 2^2
• 08 = 2^3
• 16 = 2^4
• 32 = 2^5
• 64 = 2^6
• 128 = 2^7
• 256 = 2^8
• 512 = 2^9
• 1024 = 2^10
• 2048 = 2^11
• 4096 = 2^12
• 8192 = 2^13
• 16384 = 2^14
• 32768 = 2^15
• 65536 = 2^16
• 131072 = 2^17
• 262144 = 2^18
• 524288 = 2^19
• 1048576 = 2^20
• 2097152 = 2^21
• 4194304 = 2^22
[...]

The final digit of 2^p falls into a loop: 2 → 4 → 8 → 6 → 2 → 4→ 8…

Now try the final two digits of 2^p:

02 = 2^1
04 = 2^2
08 = 2^3
16 = 2^4
32 = 2^5
64 = 2^6
• 128 = 2^7
• 256 = 2^8
• 512 = 2^9
• 1024 = 2^10
• 2048 = 2^11
• 4096 = 2^12
• 8192 = 2^13
• 16384 = 2^14
• 32768 = 2^15
• 65536 = 2^16
• 131072 = 2^17
• 262144 = 2^18
• 524288 = 2^19
• 1048576 = 2^20
• 2097152 = 2^21
• 4194304 = 2^22
• 8388608 = 2^23
• 16777216 = 2^24
• 33554432 = 2^25
• 67108864 = 2^26
• 134217728 = 2^27
• 268435456 = 2^28
• 536870912 = 2^29
• 1073741824 = 2^30
[...]

Now there’s a longer loop: 02 → 04 → 08 → 16 → 32 → 64 → 28 → 56 → 12 → 24 → 48 → 96 → 92 → 84 → 68 → 36 → 72 → 44 → 88 → 76 → 52 → 04 → 08 → 16 → 32 → 64 → 28… Any number of trailing digits, 1 or 2 or one trillion, falls into a loop. It just takes longer as the number of trailing digits increases.

That’s the tail of the snake. At the other end, the head of the snake, the digits don’t fall into a loop (because of the carries from the lower digits). So, while you can get only 2, 4, 8 and 6 as the final digits of 2^p, you can get any digit but 0 as the first digit of 2^p. Indeed, I conjecture (but can’t prove) that not only will all integers eventually appear as the leading digits of 2^p, but they will do so infinitely often. Think of a number and it will appear as the leading digits of 2^p. Let’s try the numbers 1, 12, 123, 1234, 12345…:

16 = 2^4
128 = 2^7
12379400392853802748... = 2^90
12340799625835686853... = 2^1545
12345257952011458590... = 2^34555
12345695478410965346... = 2^63293
12345673811591269861... = 2^4869721
12345678260232358911... = 2^5194868
12345678999199154389... = 2^62759188

But what about the numbers 9, 98, 987, 986, 98765… as leading digits of 2^p? They don’t appear as quickly:

9007199254740992 = 2^53
98079714615416886934... = 2^186
98726397006685494828... = 2^1548
98768356967522174395... = 2^21257
98765563827287722773... = 2^63296
98765426081858871289... = 2^5194871
98765430693066680199... = 2^11627034
98765432584491513519... = 2^260855656
98765432109571471006... = 2^1641098748

Why do fragments of 123456789 appear much sooner than fragments of 987654321? Well, even though all integers occur infinitely often as leading digits of 2^p, some integers occur more often than others, as it were. The leading digits of 2^p are actually governed by a fascinating mathematical phenomenon known as Benford’s law, which states, for example, that the single first digit, d, will occur with the frequency log10(1 + 1/d). Here are the actual frequencies of 1..9 for all powers of 2 up to 2^101000, compared with the estimate by Benford’s law:

1: 30% of leading digits ↔ 30.1% estimated
2: 17.55% ↔ 17.6%
3: 12.45% ↔ 12.49%
4: 09.65% ↔ 9.69%
5: 07.89% ↔ 7.92%
6: 06.67% ↔ 6.69%
7: 05.77% ↔ 5.79%
8: 05.09% ↔ 5.11%
9: 04.56% ↔ 4.57%

Because (inter alia) 1 appears as the first digit of 2^p far more often than 9 does, the fragments of 123456789 appear faster than the fragments of 987654321. Mutatis mutandis, the same applies in all other bases (apart from bases that are powers of 2, where there’s a single leading digit, 1, 2, 4, 8…, followed by 0s). But although a number like 123456789 occurs much frequently than 987654321 in 2^p expressed in base 10 (and higher), both integers occur infinitely often.

As do all other integers. And because stories can be expressed as numbers, all stories ever (and never) written appear in the powers of 2. Infinitely often. You’ll just have to trim the tail of the story-snake.

Sliv and Let Tri

Fluvius, planus et altus, in quo et agnus ambulet et elephas natet,” wrote Pope Gregory the Great (540-604). “There’s a river, wide and deep, where a lamb may wade and an elephant swim.” He was talking about the Word of God, but you can easily apply his words to mathematics. However, in the river of mathematics, the very shallow and the very deep are often a single step apart.

Here’s a good example. Take the integer 2. How many different ways can it be represented as an sum of separate integers? Easy. First of all it can be represented as itself: 2 = 2. Next, it can be represented as 2 = 1 + 1. And that’s it. There are two partitions of 2, as mathematicians say:

2 = 2 = 1+1 (p=2)


Now try 3, 4, 5, 6:

3 = 3 = 1+2 = 1+1+1 (p=3)
4 = 4 = 1+3 = 2+2 = 1+1+2 = 1+1+1+1 (p=5)
5 = 5 = 1+4 = 2+3 = 1+1+3 = 1+2+2 = 1+1+1+2 = 1+1+1+1+1 (p=7)
6 = 6 = 1+5 = 2+4 = 3+3 = 1+1+4 = 1+2+3 = 2+2+2 = 1+1+1+3 = 1+1+2+2 = 1+1+1+1+2 = 1+1+1+1+1+1 (p=11)


So the partitions of 2, 3, 4, 5, 6 are 2, 3, 5, 7, 11. That’s interesting — the partition-counts are the prime numbers in sequence. So you might conjecture that p(7) = 13 and p(8) = 17. Alas, you’d be wrong. Here are the partitions of n = 1..10:

1 = 1 (p=1)
2 = 2 = 1+1 (p=2)
3 = 3 = 1+2 = 1+1+1 (p=3)
4 = 4 = 1+3 = 2+2 = 1+1+2 = 1+1+1+1 (p=5)
5 = 5 = 1+4 = 2+3 = 1+1+3 = 1+2+2 = 1+1+1+2 = 1+1+1+1+1 (p=7)
6 = 6 = 1+5 = 2+4 = 3+3 = 1+1+4 = 1+2+3 = 2+2+2 = 1+1+1+3 = 1+1+2+2 = 1+1+1+1+2 = 1+1+1+1+1+1 (p=11)
7 = 7 = 1+6 = 2+5 = 3+4 = 1+1+5 = 1+2+4 = 1+3+3 = 2+2+3 = 1+1+1+4 = 1+1+2+3 = 1+2+2+2 = 1+1+1+1+3 = 1+1+1+2+2 = 1+1+1+1+1+2 = 1+1+1+1+1+1+1 (p=15)
8 = 8 = 1+7 = 2+6 = 3+5 = 4+4 = 1+1+6 = 1+2+5 = 1+3+4 = 2+2+4 = 2+3+3 = 1+1+1+5 = 1+1+2+4 = 1+1+3+3 = 1+2+2+3 = 2+2+2+2 = 1+1+1+1+4 = 1+1+1+2+3 = 1+1+2+2+2 = 1+1+1+1+1+3 = 1+1+1+1+2+2 = 1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1 (p=22)
9 = 9 = 1+8 = 2+7 = 3+6 = 4+5 = 1+1+7 = 1+2+6 = 1+3+5 = 1+4+4 = 2+2+5 = 2+3+4 = 3+3+3 = 1+1+1+6 = 1+1+2+5 = 1+1+3+4 = 1+2+2+4 = 1+2+3+3 = 2+2+2+3 = 1+1+1+1+5 = 1+1+1+2+4 = 1+1+1+3+3 = 1+1+2+2+3 = 1+2+2+2+2 = 1+1+1+1+1+4 = 1+1+1+1+2+3 = 1+1+1+2+2+2 = 1+1+1+1+1+1+3 = 1+1+1+1+1+2+2 = 1+1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1+1 (p=30)
10 = 10 = 1+9 = 2+8 = 3+7 = 4+6 = 5+5 = 1+1+8 = 1+2+7 = 1+3+6 = 1+4+5 = 2+2+6 = 2+3+5 = 2+4+4 = 3+3+4 = 1+1+1+7 = 1+1+2+6 = 1+1+3+5 = 1+1+4+4 = 1+2+2+5 = 1+2+3+4 = 1+3+3+3 = 2+2+2+4 = 2+2+3+3 = 1+1+1+1+6 = 1+1+1+2+5 = 1+1+1+3+4 = 1+1+2+2+4 = 1+1+2+3+3 = 1+2+2+2+3 = 2+2+2+2+2 = 1+1+1+1+1+5 = 1+1+1+1+2+4 = 1+1+1+1+3+3 = 1+1+1+2+2+3 = 1+1+2+2+2+2 = 1+1+1+1+1+1+4 = 1+1+1+1+1+2+3 = 1+1+1+1+2+2+2 = 1+1+1+1+1+1+1+3 = 1+1+1+1+1+1+2+2 = 1+1+1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1+1+1 (p=42)


It’s very simple to understand what a partition is, but very difficult to say how many partitions, p(n), a particular number will have. Here’s a partition: 11 = 4 + 3 + 2 + 2. But what is p(11)? Is there a formula for the sequence of p(n)?

1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310, 14883, 17977, 21637, 26015, 3118 5, 37338, 44583, 53174, 63261... (A000041 at the OEIS)

Yes, there is a formula, but it is very difficult to understand the Partition function that supplies it. So that part of the river of mathematics is very deep. But a step away the river of mathematics is very shallow. Here’s another question: If you multiply the numbers in a partition of n, what’s the largest possible product? Try using the partitions of 5:

4 = 1 * 4
6 = 2 * 3
3 = 1 * 1 * 3
4 = 1 * 2 * 2
2 = 1 * 1 * 1 * 2
1 = 1 * 1 * 1 * 1 * 1

The largest product is 6 = 2 * 3. So the answer is easy for n = 5, but I assumed that as n got bigger, the largest product got more interesting, using a subtler and subtler mix of prime factors. I was wrong. You don’t have to struggle to find a formula for what you might call the maximum multiplicity of the partitions of n:

1 = 1 (n=1)
2 = 2 (n=2)
3 = 3 (n=3)
4 = 2 * 2 (n=4)
6 = 2 * 3 (n=5)
9 = 3 * 3 (n=6)
12 = 2 * 2 * 3 (n=7)
18 = 2 * 3 * 3 (n=8)
27 = 3 * 3 * 3 (n=9)
36 = 2 * 2 * 3 * 3 (n=10)
54 = 2 * 3 * 3 * 3 (n=11)
81 = 3 * 3 * 3 * 3 (n=12)
108 = 2 * 2 * 3 * 3 * 3 (n=13)
162 = 2 * 3 * 3 * 3 * 3 162(n=14)
243 = 3 * 3 * 3 * 3 * 3 (n=15)
324 = 2 * 2 * 3 * 3 * 3 * 3 (n=16)
486 = 2 * 3 * 3 * 3 * 3 * 3 (n=17)
729 = 3 * 3 * 3 * 3 * 3 * 3 (n=18)


It’s easy to see why the greatest prime factor is always 3. If you use 5 or 7 as a factor, the product can always be beaten by splitting the 5 into 2*3 or the 7 into 2*2*3:

15 = 3 * 5 < 18 = 3 * 2*3 (n=8)
14 = 2 * 7 < 24 = 2 * 2*2*3 (n=9)
35 = 5 * 7 < 72 = 2*3 * 2*2*3 (n=12)

And if you’re using 7 → 2*2*3 as factors, you can convert them to 1*3*3, then add the 1 to another factor to make a bigger product still:

14 = 2 * 7 < 24 = 2 * 2*2*3 < 27 = 3 * 3 * 3 (n=9)
35 = 5 * 7 < 72 = 2*3 * 2*2*3 < 81 = 3 * 3 * 3 * 3 (n=12)


Post-Performative Post-Scriptum

The title of this post is, of course, a paronomasia on core Beatles album Live and Let Die (1954). But what does it mean? Well, if you think of the partitions of n as slivers of n, then you sliv n to find its partitions:

9 = 9 = 1+8 = 2+7 = 3+6 = 4+5 = 1+1+7 = 1+2+6 = 1+3+5 = 1+4+4 = 2+2+5 = 2+3+4 = 3+3+3 = 1+1+1+6 = 1+1+2+5 = 1+1+3+4 = 1+2+2+4 = 1+2+3+3 = 2+2+2+3 = 1+1+1+1+5 = 1+1+1+2+4 = 1+1+1+3+3 = 1+1+2+2+3 = 1+2+2+2+2 = 1+1+1+1+1+4 = 1+1+1+1+2+3 = 1+1+1+2+2+2 = 1+1+1+1+1+1+3 = 1+1+1+1+1+2+2 = 1+1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1+1 (p=30)

And when you find the greatest product among those partitions, you let 3 or “tri” work its multiplicative magic. So you “Sliv and Let Tri”:

8 = 1 * 8
14 = 2 * 7
18 = 3 * 6
20 = 4 * 5
7 = 1 * 1 * 7
12 = 1 * 2 * 6
15 = 1 * 3 * 5
16 = 1 * 4 * 4
20 = 2 * 2 * 5
24 = 2 * 3 * 4
27 = 3 * 3 * 3 ←
6 = 1 * 1 * 1 * 6
10 = 1 * 1 * 2 * 5
12 = 1 * 1 * 3 * 4
16 = 1 * 2 * 2 * 4
12 = 1 * 2 * 3 * 3
24 = 2 * 2 * 2 * 3
5 = 1 * 1 * 1 * 1 * 5
8 = 1 * 1 * 1 * 2 * 4
9 = 1 * 1 * 1 * 3 * 3
12 = 1 * 1 * 2 * 2 * 3
16 = 1 * 2 * 2 * 2 * 2
4 = 1 * 1 * 1 * 1 * 1 * 4
6 = 1 * 1 * 1 * 1 * 2 * 3
8 = 1 * 1 * 1 * 2 * 2 * 2
3 = 1 * 1 * 1 * 1 * 1 * 1 * 3
4 = 1 * 1 * 1 * 1 * 1 * 2 * 2
2 = 1 * 1 * 1 * 1 * 1 * 1 * 1 * 2
1 = 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1

Digital Dissection

As I never tire of pointing out, the three most powerful drugs in the universe are water, maths and language. And I never tire of snorting the fact that numbers can come in many different guises. You can take a trivial, everyday number like a hundred and see it transform like this:


100 = 1100100 in base 2; 10201 in base 3; 1210 in base 4; 400 in base 5; 244 in base 6; 202 in base 7; 144 in base 8; 121 in base 9; 100 in b10; 91 in b11; 84 in b12; 79 in b13; 72 in b14; 6A in b15; 64 in b16; 5F in b17; 5A in b18; 55 in b19; 50 in b20; 4G in b21; 4C in b22; 48 in b23; 44 in b24; 40 in b25; 3M in b26; 3J in b27; 3G in b28; 3D in b29; 3A in b30; 37 in b31; 34 in b32; 31 in b33; 2W in b34; 2U in b35; 2S in b36; 2Q in b37; 2O in b38; 2M in b39; 2K in b40; 2I in b41; 2G in b42; 2E in b43; 2C in b44; 2A in b45; 28 in b46; 26 in b47; 24 in b48; 22 in b49; 20 in b50; 1[49] in b51; 1[48] in b52; 1[47] in b53; 1[46] in b54; 1[45] in b55; 1[44] in b56; 1[43] in b57; 1[42] in b58; 1[41] in b59; 1[40] in b60; 1[39] in b61; 1[38] in b62; 1[37] in b63; 1[36] in b64; 1Z in b65; 1Y in b66; 1X in b67; 1W in b68; 1V in b69; 1U in b70; 1T in b71; 1S in b72; 1R in b73; 1Q in b74; 1P in b75; 1O in b76; 1N in b77; 1M in b78; 1L in b79; 1K in b80; 1J in b81; 1I in b82; 1H in b83; 1G in b84; 1F in b85; 1E in b86; 1D in b87; 1C in b88; 1B in b89; 1A in b90; 19 in b91; 18 in b92; 17 in b93; 16 in b94; 15 in b95; 14 in b96; 13 in b97; 12 in b98; 11 in b99

I like the shifts from 1100100 to 10201 to 1210 to 400 to 244 to 202 to 144 to 121. How can 1100100 and 244 be the same number? Well, they are — or they’re not, as you please. In base 2, 1100100 = 244 in base 6 = 100 in base 10. But if all those numbers are in the same base, they’re completely different and 1100100 dwarfs the other two.

But some things you can’t please yourself about. Suppose you take the different representations of 6561 in bases 2..6560 and add up the 1s, the 2s, the 3s and so on, like this:


n=6561

digsum(1,6561,b=2..6560) = 3343 (50.95% of 6561)
digsum(2,6561,b=2..6560) = 2246 (34.23% of 6561)
digsum(3,6561,b=2..6560) = 1680 (25.61% of 6561)
digsum(4,6561,b=2..6560) = 1368 (20.85% of 6561)
digsum(5,6561,b=2..6560) = 1185 (18.06% of 6561)
digsum(6,6561,b=2..6560) = 1074 (16.37% of 6561)
digsum(7,6561,b=2..6560) = 875 (13.34% of 6561)
digsum(8,6561,b=2..6560) = 768 (11.71% of 6561)
digsum(9,6561,b=2..6560) = 1080 (16.46% of 6561)
[...]
digcount(0,6561,b=2..6560) = 31

Is there a pattern in the percentages? Let’s apply the same process to some bigger numbers (and note that 0 does not behave like the other digits):


n=59049

digsum(1,59049) = 29648 (50.21%)
digsum(2,59049) = 19790 (33.51%)
digsum(3,59049) = 14901 (25.23%)
digsum(4,59049) = 11956 (20.25%)
digsum(5,59049) = 9970 (16.88%)
digsum(6,59049) = 8550 (14.48%)
digsum(7,59049) = 7539 (12.77%)
digsum(8,59049) = 6672 (11.30%)
digsum(9,59049) = 6579 (11.14%)
digcount(0,59049) = 41


n=531441

digsum(1,531441) = 266065 (50.06%)
digsum(2,531441) = 177394 (33.38%)
digsum(3,531441) = 133128 (25.05%)
digsum(4,531441) = 106532 (20.05%)
digsum(5,531441) = 88815 (16.71%)
digsum(6,531441) = 76224 (14.34%)
digsum(7,531441) = 66661 (12.54%)
digsum(8,531441) = 59320 (11.16%)
digsum(9,531441) = 53928 (10.15%)
digcount(0,531441) = 62


n=4782969

digsum(1,4782969) = 2392219 (50.02%)
digsum(2,4782969) = 1595000 (33.35%)
digsum(3,4782969) = 1196370 (25.01%)
digsum(4,4782969) = 957300 (20.01%)
digsum(5,4782969) = 797700 (16.68%)
digsum(6,4782969) = 683850 (14.30%)
digsum(7,4782969) = 598444 (12.51%)
digsum(8,4782969) = 531944 (11.12%)
digsum(9,4782969) = 480870 (10.05%)
digcount(0,4782969) = 66

Yes, the pattern’s getting stronger. Let’s try even bigger numbers:


n=43046721

digsum(1,43046721) = 21525521 (50.01%)
digsum(2,43046721) = 14350754 (33.34%)
digsum(3,43046721) = 10763496 (25.00%)
digsum(4,43046721) = 8610980 (20.00%)
digsum(5,43046721) = 7175955 (16.67%)
digsum(6,43046721) = 6150924 (14.29%)
digsum(7,43046721) = 5382167 (12.50%)
digsum(8,43046721) = 4784232 (11.11%)
digsum(9,43046721) = 4306257 (10.00%)
digcount(0,43046721) = 86


n=387420489

digsum(1,387420489) = 193716365 (50.00%)
digsum(2,387420489) = 129145522 (33.33%)
digsum(3,387420489) = 96859980 (25.00%)
digsum(4,387420489) = 77488588 (20.00%)
digsum(5,387420489) = 64574220 (16.67%)
digsum(6,387420489) = 55349742 (14.29%)
digsum(7,387420489) = 48431250 (12.50%)
digsum(8,387420489) = 43050264 (11.11%)
digsum(9,387420489) = 38748357 (10.00%)
digcount(0,387420489) = 95

To the given precision, the sum of 1s is 1/2 of n; the sum of 2s is 1/3; the sum of 3 is 1/4; and the sum of 4s is 1/5. It looks as though the sum of a given digit d → 1/(d+1) of n as n → ∞. But why? My mathematical intuition is bad, so it took me a while to see what some people will see in a flash. To see what’s going on, let’s go back to the all-base representations of 100:


100 = 1100100 in base 2; 10201 in base 3; 1210 in base 4; 400 in base 5; 244 in base 6; 202 in base 7; 144 in base 8; 121 in base 9; 100 in b10; 91 in b11; 84 in b12; 79 in b13; 72 in b14; 6A in b15; 64 in b16; 5F in b17; 5A in b18; 55 in b19; 50 in b20; 4G in b21; 4C in b22; 48 in b23; 44 in b24; 40 in b25; 3M in b26; 3J in b27; 3G in b28; 3D in b29; 3A in b30; 37 in b31; 34 in b32; 31 in b33; 2W in b34; 2U in b35; 2S in b36; 2Q in b37; 2O in b38; 2M in b39; 2K in b40; 2I in b41;
2G in b42; 2E in b43; 2C in b44; 2A in b45; 28 in b46; 26 in b47; 24 in b48; 22 in b49; 20 in b50; 1[49] in b51; 1[48] in b52; 1[47] in b53; 1[46] in b54; 1[45] in b55; 1[44] in b56; 1[43] in b57; 1[42] in b58; 1[41] in b59; 1[40] in b60; 1[39] in b61; 1[38] in b62; 1[37] in b63; 1[36] in b64; 1Z in b65; 1Y in b66; 1X in b67; 1W in b68; 1V in b69; 1U in b70; 1T in b71; 1S in b72; 1R in b73; 1Q in b74; 1P in b75; 1O in b76; 1N in b77; 1M in b78; 1L in b79; 1K in b80; 1J in b81
; 1I in b82; 1H in b83; 1G in b84; 1F in b85; 1E in b86; 1D in b87; 1C in b88; 1B in b89; 1A in b90; 19 in b91; 18 in b92; 17 in b93; 16 in b94; 15 in b95; 14 in b96; 13 in b97; 12 in b98; 11 in b99

When the base b is higher than half of 100, the representations of 100 consist of a digit 1 followed by another digit. Half of a hundred = 50, therefore 100 in base 10 = 1[49] in b51, 1[48] in b52, 1[47] in b53, 1[46] in b54, 1[45] in b55, 1[44] in b56, 1[43] in b57, 1[42] in b58, 1[41] in b59… If you take binary and so on into account, 1 is the first digit of slightly over half the representations of 100. And 1 also occurs in other positions. Therefore digsum(1,100,b=2..99) > 50. As the number n gets larger and larger, the contribution of leading 1s in bases b > n/2 begins to swamp the contributions of 1s in other positions, therefore digsum(1,n) → 1/2 of n as n → ∞.

And what about 2s and 3s? Similar reasoning applies. One hundred has a leading digit of 2 in bases b where b > 1/3 of 100 and b <= 1/2 of 100. So 100 = 2W in b34, 2U in b35, 2S in b36, 2Q in b37, 2O in b38… In other words, roughly 1/2 – 1/3 of the representations of 100 have a leading 2. Now, 1/2 – 1/3 = 3/6 – 2/6 = 1/6 and 1/6 * 2 = 1/3 (i.e., 1/6 of the representations contribute a leading 2 to the sum of 2s). Therefore the all-base digsum(2,n) → 1/3 of n as n → ∞. Next, one hundred has a leading digit of 3 in bases b where b > 1/4 of 100 and b <= 1/3. So 100 = 3M in b26, 3J in b27, 3G in b28, 3D in b29, 3A in b30… Now, 1/3 – 1/4 = 4/12 – 3/12 = 1/12 and 1/12 * 3 = 1/4. Therefore the all-base digsum(3,n) → 1/4 of n as n → ∞.

And so on.

Zequality Now

Here are the numbers one to eight in base 2:

1, 10, 11, 100, 101, 110, 111, 1000…

Now see what happens when you count the zeroes:


1, 10[1], 11, 10[2]0[3], 10[4]1, 110[5], 111, 10[6]0[7]0[8]...

In base 2, the numbers one to eight contain exactly eight zeroes, that is, zerocount(1..8,b=2) = 8. But it doesn’t work out so exactly in base 3:


1, 2, 10[1], 11, 12, 20[2], 21, 22, 10[3]0[4], 10[5]1, 10[6]2, 110[7], 111, 112, 120[8], 121, 122, 20[9]0[10], 20[11]1, 20[12]2, 210[13], 211, 212, 220[14], 221, 222, 10[15]0[16]0[17], 10[18]0[19]1, 10[20]0[21]2, 10[22]10[23], 10[24]11, 10[25]12, 10[26]20[27], 10[28]21, 10[29]22, 110[30]0[31], 110[32]1, 110[33]2, 1110[34], 1111, 1112, 1120[35], 1121, 1122, 120[36]0[37], 120[38]1, 120[39]2, 1210[40], 1211, 1212, 1220[41], 1221, 1222, 20[42]0[43]0[44], 20[45]0[46]1, 20[47]0[48]2, 20[49]10[50], 20[51]11, 20[52]12, 20[53]20[54], 20[55]21, 20[56]22, 210[57]0[58], 210[59]1, 210[60]2, 2110[61], 2111, 2112, 2120[62], 2121, 2122, 220[63]0[64], 220[65]1, 220[66]2, 2210[67], 2211, 2212, 2220[68], 2221, 2222, 10[69]0[70]0[71]0[72], 10[73]0[74]0[75]1, 10[76]0[77]0[78]2, 10[79]0[80]10[81], 10[82]0[83]11, 10[84]0[85]12, 10[86]0[87]20[88]...

In base 3, 10020 = 87 and zerocount(1..87,b=3) = 88. And what about base 4? zerocount(1..1068,b=4) = 1069 (n=100,230 in base 4). After that, zerocount(1..16022,b=5) = 16023 (n=1,003,043 in base 5) and zerocount(1..284704,b=6) = 284,705 (n=10,034,024 in base 6).

The numbers are getting bigger fast and it’s becoming increasingly impractible to count the zeroes individually. What you need is an algorithm that will take any given n and work out how many zeroes are required to write the numbers 1 to n. The simplest way to do this is to work out how many times 0 has appeared in each position of the number. The 1s position is easy: you simply divide the number by the base and discard the remainder. For example, in base 10, take the number 25. The 0 must have appeared in the 1s position twice, for 10 and 20, so zerocount(1..25) = 25 \ 10 = 2. In 2017, the 0 must have appeared in the 1s position 201 times = 2017 \ 10. And so on.

It gets a little trickier for the higher positions, the 10s, 100s, 1000s and so on, but the same basic principle applies. And so you can easily create an algorithm that takes a number, n, and produces zerocount(1..n) in a particular base. With this algorithm, you can quickly find zerocount(1..n) >= n in higher bases:


zerocount(1..1000,b=2) = 1,000 (n=8)*
zerocount(1..10020,b=3) = 10,021 (n=87)
zerocount(1..100230,b=4) = 100,231 (n=1,068)
zerocount(1..1003042,b=5) = 1,003,043 (n=16,022)
zerocount(1..10034024,b=6) = 10,034,025 (n=284,704)
zerocount(1..100405550,b=7) = 100,405,551 (n=5,834,024)
zerocount(1..1004500236,b=8) = 1,004,500,237 (n=135,430,302)
zerocount(1..10050705366,b=9) = 10,050,705,367 (n=3,511,116,537)
zerocount(1..100559404366,b=10) = 100,559,404,367
zerocount(1..1006083A68919,b=11) = 1,006,083,A68,919 (n=3,152,738,985,031)*
zerocount(1..10066AA1430568,b=12) = 10,066,AA1,430,569 (n=107,400,330,425,888)
zerocount(1..1007098A8719B81,b=13) = 100,709,8A8,719,B81 (n=3,950,024,143,546,664)*
zerocount(1..10077C39805D81C7,b=14) = 1,007,7C3,980,5D8,1C8 (n=155,996,847,068,247,395)
zerocount(1..10080B0034AA5D16D,b=15) = 10,080,B00,34A,A5D,171 (n=6,584,073,072,068,125,453)
zerocount(1..10088DBE29597A6C77,b=16) = 100,88D,BE2,959,7A6,C77 (n=295,764,262,988,176,583,799)*
zerocount(1..10090C5309AG72CBB3F,b=17) = 1,009,0C5,309,AG7,2CB,B3G (n=14,088,968,131,538,370,019,982)
zerocount(1..10099F39070FC73C1G73,b=18) = 10,099,F39,070,FC7,3C1,G75 (n=709,394,716,006,812,244,474,473)
zerocount(1..100A0DC1258614CA334EB,b=19) = 100,A0D,C12,586,14C,A33,4EC (n=37,644,984,315,968,494,382,106,708)
zerocount(1..100AAGDEEB536IBHE87006,b=20) = 1,00A,AGD,EEB,536,IBH,E87,008 (n=2,099,915,447,874,594,268,014,136,006)

And you can also easily find the zequal numbers, that is, the numbers n for which, in some base, zerocount(1..n) exactly equals n:


zerocount(1..1000,b=2) = 1,000 (n=8)
zerocount(1..1006083A68919,b=11) = 1,006,083,A68,919 (n=3,152,738,985,031)
zerocount(1..1007098A8719B81,b=13) = 100,709,8A8,719,B81 (n=3,950,024,143,546,664)
zerocount(1..10088DBE29597A6C77,b=16) = 100,88D,BE2,959,7A6,C77 (n=295,764,262,988,176,583,799)
zerocount(1..100CCJFFAD4MI409MI0798CJB3,b=24) = 10,0CC,JFF,AD4,MI4,09M,I07,98C,JB3 (n=32,038,681,563,209,056,709,427,351,442,469,835)
zerocount(1..100DDL38CIO4P9K0AJ7HK74EMI7L,b=26) = 1,00D,DL3,8CI,O4P,9K0,AJ7,HK7,4EM,I7L (n=160,182,333,966,853,031,081,693,091,544,779,177,187)
zerocount(1..100EEMHG6OE8EQKO0BF17LCCIA7GPE,b=28) = 100,EEM,HG6,OE8,EQK,O0B,F17,LCC,IA7,GPE (n=928,688,890,453,756,699,447,122,559,347,771,300,777,482)
zerocount(1..100F0K7MQO6K9R1S616IEEL2JRI73PF,b=29) = 1,00F,0K7,MQO,6K9,R1S,616,IEE,L2J,RI7,3PF (n=74,508,769,042,363,852,559,476,397,161,338,769,391,145,562)
zerocount(1..100G0LIL0OQLF2O0KIFTK1Q4DC24HL7BR,b=31) = 100,G0L,IL0,OQL,F2O,0KI,FTK,1Q4,DC2,4HL,7BR (n=529,428,987,529,739,460,369,842,168,744,635,422,842,585,510,266)
zerocount(1..100H0MUTQU3A0I5005WL2PD7T1ASW7IV7NE,b=33) = 10,0H0,MUT,QU3,A0I,500,5WL,2PD,7T1,ASW,7IV,7NE (n=4,262,649,311,868,962,034,947,877,223,846,561,239,424,294,726,563,632)
zerocount(1..100HHR387RQHK9OP6EDBJEUDAK35N7MN96LB,b=34) = 100,HHR,387,RQH,K9O,P6E,DBJ,EUD,AK3,5N7,MN9,6LB (n=399,903,937,958,473,433,782,862,763,628,747,974,628,490,691,628,136,485)
zerocount(1..100IISLI0CYX2893G9E8T4I7JHKTV41U0BKRHT,b=36) = 10,0II,SLI,0CY,X28,93G,9E8,T4I,7JH,KTV,41U,0BK,RHT (n=3,831,465,379,323,568,772,890,827,210,355,149,992,132,716,389,119,437,755,185)
zerocount(1..100LLX383BPWE[40]ZL0G1M[40]1OX[39]67KOPUD5C[40]RGQ5S6W9[36],b=42) = 10,0LL,X38,3BP,WE[40],ZL0,G1M,[40]1O,X[39]6,7KO,PUD,5C[40],RGQ,5S6,W9[36] (n=6,307,330,799,917,244,669,565,360,008,241,590,852,337,124,982,231,464,556,869,653,913,711,854)
zerocount(1..100MMYPJ[38]14KDV[37]OG[39]4[42]X75BE[39][39]4[43]CK[39]K36H[41]M[37][43]5HIWNJ,b=44) = 1,00M,MYP,J[38]1,4KD,V[37]O,G[39]4,[42]X7,5BE,[39][39]4,[43]CK,[39]K3,6H[41],M[37][43],5HI,WNJ (n=90,257,901,046,284,988,692,468,444,260,851,559,856,553,889,199,511,017,124,021,440,877,333,751,943)
zerocount(1..100NN[36]3813[38][37]16F6MWV[41]UBNF5FQ48N0JRN[40]E76ZOHUNX2[42]3[43],b=46) = 100,NN[36],381,3[38][37],16F,6MW,V[41]U,BNF,5FQ,48N,0JR,N[40]E,76Z,OHU,NX2,[42]3[43] (n=1,411,636,908,622,223,745,851,790,772,948,051,467,006,489,552,352,013,745,000,752,115,904,961,213,172,605)
zerocount(1..100O0WBZO9PU6O29TM8Y0QE3I[37][39]A7E4YN[44][42]70[44]I[46]Z[45][37]Q2WYI6,b=47) = 1,00O,0WB,ZO9,PU6,O29,TM8,Y0Q,E3I,[37][39]A,7E4,YN[44],[42]70,[44]I[46],Z[45][37],Q2W,YI6 (n=182,304,598,281,321,725,937,412,348,242,305,189,665,300,088,639,063,301,010,710,450,793,661,266,208,306,996)
zerocount(1..100PP[39]37[49]NIYMN[43]YFE[44]TDTJ00EAEIP0BIDFAK[46][36]V6V[45]M[42]1M[46]SSZ[40],b=50) = 1,00P,P[39]3,7[49]N,IYM,N[43]Y,FE[44],TDT,J00,EAE,IP0,BID,FAK,[46][36]V,6V[45],M[42]1,M[46]S,SZ[40] (n=444,179,859,561,011,965,929,496,863,186,893,220,413,478,345,535,397,637,990,204,496,296,663,272,376,585,291,071,790)
zerocount(1..100Q0Y[46][44]K[49]CKG[45]A[47]Z[43]SPZKGVRN[37]2[41]ZPP[36]I[49][37]EZ[38]C[44]E[46]00CG[38][40][48]ROV,b=51) = 10,0Q0,Y[46][44],K[49]C,KG[45],A[47]Z,[43]SP,ZKG,VRN,[37]2[41],ZPP,[36]I[49],[37]EZ,[38]C[44],E[46]0,0CG,[38][40][48],ROV (n=62,191,970,278,446,971,531,566,522,791,454,395,351,613,891,150,548,291,266,262,575,754,206,359,828,753,062,692,619,547)
zerocount(1..100QQ[40]TL[39]ZA[49][41]J[41]7Q[46]4[41]66A1E6QHHTM9[44]8Z892FRUL6V[46]1[38][41]C[40][45]KB[39],b=52) = 100,QQ[40],TL[39],ZA[49],41]J[41],7Q[46],4[41]6,6A1,E6Q,HHT,M9[44],8Z8,92F,RUL,6V[46],1[38][41],C[40][45],KB[39] (n=8,876,854,501,927,007,077,802,489,292,131,402,136,556,544,697,945,824,257,389,527,114,587,644,068,732,794,430,403,381,731)
zerocount(1..100S0[37]V[53]Y6G[51]5J[42][38]X[40]XO[38]NSZ[42]XUD[47]1XVKS[52]R[39]JAHH[49][39][50][54]5PBU[42]H3[45][46]DEJ,b=55) = 100,S0[37],V[53]Y,6G[51],5J[42],[38]X[40],XO[38],NSZ,[42]XU,D[47]1,XVK,S[52]R,[39]JA,HH[49],[39][50][54],5PB,U[42]H,3[45][46],DEJ (n=28,865,808,580,366,629,824,612,818,017,012,809,163,332,327,132,687,722,294,521,718,120,736,868,268,650,080,765,802,786,141,387,114)

Can You Dij It? #2

It’s very simple, but I’m fascinated by it. I’m talking about something I call the digit-line, or the stream of digits you get when you split numbers in a particular base into individual digits. For example, here are the numbers one to ten in bases 2 and 3:

Base = 2: 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010…
Base = 3: 1, 2, 10, 11, 12, 20, 21, 22, 100, 101…


If you turn them into digit-lines, they look like this:

Base = 2: 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0… (A030190 in the Online Encyclopedia of Integer Sequences)
Base = 3: 1, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2, 1, 0, 0, 1, 0, 1… (A003137 in the OEIS)


At the tenth digit of the two digit-lines, both digits equal zero for the first time:

Base = 2: 1, 1, 0, 1, 1, 1, 0, 0, 1, 0
Base = 3: 1, 2, 1, 0, 1, 1, 1, 2, 2, 0


When the binary and ternary digits are represented together, the digit-lines look like this:

(1,1), (1,2), (0,1), (1,0), (1,1), (1,1), (0,1), (0,2), (1,2), (0,0)


But in base 4, the tenth digit of the digit-line is 1. So when do all the digits of the digit-line first equal zero for bases 2 to 4? Here the early integers in those bases:

Base 2: 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, 10010, 10011, 10100, 10101…

Base 3: 1, 2, 10, 11, 12, 20, 21, 22, 100, 101, 102, 110, 111, 112, 120, 121, 122, 200, 201, 202, 210, 211, 212, 220, 221, 222, 1000, 1001, 1002…

Base 4: 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33, 100, 101, 102, 103, 110, 111, 112, 113, 120, 121, 122, 123, 130, 131, 132, 133, 200…


And here are the digits of the digit-line in bases 2 to 4 represented together:

(1,1,1), (1,2,2), (0,1,3), (1,0,1), (1,1,0), (1,1,1), (0,1,1), (0,2,1), (1,2,2), (0,0,1), (1,2,3), (1,1,2), (1,2,0), (0,2,2), (1,1,1), (1,0,2), (1,0,2), (1,1,2), (0,0,3), (0,1,3), (0,1,0), (1,0,3), (0,2,1), (0,1,3), (1,1,2), (1,0,3), (0,1,3), (1,1,1), (0,1,0), (1,1,0), (0,1,1), (1,2,0), (1,1,1), (1,2,1), (1,0,0), (0,1,2), (0,2,1), (1,1,0), (1,1,3), (0,2,1), (1,2,1), (1,2,0), (1,0,1), (1,0,1), (0,2,1), (1,0,1), (1,1,1), (1,2,2), (1,0,1), (1,2,1), (0,2,3), (0,1,1), (0,0,2), (0,2,0), (1,1,1), (0,1,2), (0,2,1), (0,1,1), (1,2,2), (1,2,2), (0,2,1), (0,0,2), (1,2,3), (0,2,1), (1,1,3), (0,2,0), (0,2,1), (1,2,3), (1,1,1), (1,0,1), (0,0,3), (1,0,2), (0,1,1), (0,0,3), (1,0,3), (0,1,2), (1,1,0), (0,0,0)

At the 78th digit, all three digits equal zero. But the 78th digit of the digit-line in base 5 is 1. So when are the digits first equal to zero in bases 2 to 5? It’s not difficult to find out, but the difficulty of the search increases fast as the bases get bigger. Here are the results up to base 13 (note that bases 11 and 12 both have zeroes at digit 103721663):

dig=0 in bases 2 to 3 at the 10th digit of the digit-line
dig=0 in bases 2 to 4 at the 78th digit of the digit-line
dig=0 in bases 2 to 5 at the 182nd digit of the digit-line
dig=0 in bases 2 to 6 at the 302nd digit of the digit-line
dig=0 in bases 2 to 7 at the 12149th digit of the digit-line
dig=0 in bases 2 to 8 at the 45243rd digit of the digit-line
dig=0 in bases 2 to 9 at the 255261st digit of the digit-line
dig=0 in bases 2 to 10 at the 8850623rd digit of the digit-line
dig=0 in bases 2 to 12 at the 103721663rd digit of the digit-line
dig=0 in bases 2 to 13 at the 807778264th digit of the digit-line


I assume that, for any base b > 2, you can find some point in the digit-line at which d = 0 for all bases 2 to b. Indeed, I assume that this happens infinitely often. But I don’t know any short-cut for finding the first digit at which this occurs.


Previously pre-posted:

Can You Dij It? #1

Digital Rodeo

What a difference a digit makes. Suppose you take all representations of n in bases b <= n. When n = 3, the bases are 2 and 3, so 3 = 11 and 10, respectively. Next, count the occurrences of the digit 1:

digitcount(3, digit=1, n=11, 10) = 3

Add this digit-count to 3:

3 + digitcount(3, digit=1, n=11, 10) = 3 + 3 = 6.

Now apply the same procedure to 6. The bases will be 2 to 6:

6 + digitcount(6, digit=1, n=110, 20, 12, 11, 10) = 6 + 6 = 12

The procedure, n = n + digitcount(n,digit=1,base=2..n), continues like this:

12 + digcount(12,dig=1,n=1100, 110, 30, 22, 20, 15, 14, 13, 12, 11, 10) = 12 + 11 = 23
23 + digcount(23,dig=1,n=10111, 212, 113, 43, 35, 32, 27, 25, 23, 21, 1B, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 23 + 21 = 44
44 + digcount(44,dig=1,n=101100, 1122, 230, 134, 112, 62, 54, 48, 44, 40, 38, 35, 32, 2E, 2C, 2A, 28, 26, 24, 22, 20, 1L, 1K, 1J, 1I, 1H, 1G, 1F, 1E, 1D, 1C, 1B, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 44 + 31 = 75

And the sequence develops like this:

3, 6, 12, 23, 44, 75, 124, 202, 319, 503, 780, 1196, 1824, 2766, 4191, 6338, 9546, 14383, 21656, 32562, 48930, 73494, 110361, 165714, 248733, 373303, 560214, 840602, 1261237, 1892269, 2838926, 4258966, 6389157, 9584585, 14377879…

Now try the same procedure using the digit 0: n = n + digcount(n,dig=0,base=2..n). The first step is this:

3 + digcount(3,digit=0,n=11, 10) = 3 + 1 = 4

Next come these:

4 + digcount(4,dig=0,n=100, 11, 10) = 4 + 3 = 7
7 + digcount(7,dig=0,n=111, 21, 13, 12, 11, 10) = 7 + 1 = 8
8 + digcount(8,dig=0,n=1000, 22, 20, 13, 12, 11, 10) = 8 + 5 = 13
13 + digcount(13,dig=0,n=1101, 111, 31, 23, 21, 16, 15, 14, 13, 12, 11, 10) = 13 + 2 = 15
15 + digcount(15,dig=0,n=1111, 120, 33, 30, 23, 21, 17, 16, 15, 14, 13, 12, 11, 10) = 15 + 3 = 18
18 + digcount(18,dig=0,n=10010, 200, 102, 33, 30, 24, 22, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 18 + 9 = 27
27 + digcount(27,dig=0,n=11011, 1000, 123, 102, 43, 36, 33, 30, 27, 25, 23, 21, 1D, 1C, 1B, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 27 + 7 = 34
34 + digcount(34,dig=0,n=100010, 1021, 202, 114, 54, 46, 42, 37, 34, 31, 2A, 28, 26, 24, 22, 20, 1G, 1F, 1E, 1D, 1C, 1B, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 34 + 8 = 42
42 + digcount(42,dig=0,n=101010, 1120, 222, 132, 110, 60, 52, 46, 42, 39, 36, 33, 30, 2C, 2A, 28, 26, 24, 22, 20, 1K, 1J, 1I, 1H, 1G, 1F, 1E, 1D, 1C, 1B, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 42 + 9 = 51

The sequence develops like this:

3, 4, 7, 8, 13, 15, 18, 27, 34, 42, 51, 59, 62, 66, 80, 94, 99, 111, 117, 125, 132, 151, 158, 163, 173, 180, 204, 222, 232, 244, 258, 279, 292, 307, 317, 324, 351, 364, 382, 389, 400, 425, 437, 447, 454, 466, 475, 483, 494, 509, 517, 536, 553, 566, 576, 612, 637, 649, 669, 679, 693, 712, 728, 753, 768, 801, 822, 835, 849, 862, 869, 883, 895, 906, 923, 932, 943, 949, 957, 967, 975, 999, 1011…

If you compare it with the sequence for digit=1, it appears that digcount(n,dig=1,b=2..n) is always larger than digcount(n,dig=0,b=2..n). That is in fact the case, with one exception, when n = 2:

digcount(2,dig=1,n=10) = 1
digcount(2,dig=0,n=10) = 1

When n = 10 (in base ten), there are twice as many ones as zeros:

digcount(10,dig=1,n=1010, 101, 22, 20, 14, 13, 12, 11, 10) = 10
digcount(10,dig=0,n=1010, 101, 22, 20, 14, 13, 12, 11, 10) = 5

As n gets larger, the difference grows dramatically:

digcount(100,dig=1,base=2..n) = 64
digcount(100,dig=0,base=2..n) = 16

digcount(1000,dig=1,base=2..n) = 533
digcount(1000,dig=0,base=2..n) = 25

digcount(10000,dig=1,base=2..n) = 5067
digcount(10000,dig=0,base=2..n) = 49

digcount(100000,dig=1,base=2..n) = 50140
digcount(100000,dig=0,base=2..n) = 73

digcount(1000000,dig=1,base=2..n) = 500408
digcount(1000000,dig=0,base=2..n) = 102

digcount(10000000,dig=1,base=2..n) = 5001032
digcount(10000000,dig=0,base=2..n) = 134

digcount(100000000,dig=1,base=2..n) = 50003137
digcount(100000000,dig=0,base=2..n) = 160

In fact, digcount(n,dig=1,b=2..n) is greater than the digit-count for any other digit: 0, 2, 3, 4, 5… (with the exception n = 2, as shown above). But digit=0 sometimes beats digits >= 2. For example, when n = 18:

digcount(18,dig=0,n=10010, 200, 102, 33, 30, 24, 22, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 9
digcount(18,dig=2,n=10010, 200, 102, 33, 30, 24, 22, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 7
digcount(18,dig=3,n=10010, 200, 102, 33, 30, 24, 22, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 4
digcount(18,dig=4,n=10010, 200, 102, 33, 30, 24, 22, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 2
digcount(18,dig=5,n=10010, 200, 102, 33, 30, 24, 22, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 1

But as n gets larger, digcount(0) will fall permanently behind all these digits. However, digcount(0) will always be greater than some digit d, for the obvious reason that some digits only appear when the base is high enough. For example, the hexadecimal digit A (with the decimal value 10) first appears when n = 21:

digcount(21,dig=A,n=10101, 210, 111, 41, 33, 30, 25, 23, 21, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 1 digcount(21,dig=0,n=10101, 210, 111, 41, 33, 30, 25, 23, 21, 1A, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10) = 5

There is a general rule for the n at which digit d first appears, n = 2d + 1 (this doesn’t apply when d = 0 or d = 1):

d = 2, n = 5 = 2*2 + 1
digcount(5,dig=2,n=101, 12, 11, 10) = 1

d = 3, n = 7 = 2*3 + 1
digcount(7,dig=3,n=111, 21, 13, 12, 11, 10) = 1

d = 4, n = 9 = 2*4 + 1
digcount(9,dig=4,n=1001, 100, 21, 14, 13, 12, 11, 10) = 1

d = 5, n = 11 = 2*5 + 1
digcount(11,dig=5,n=1011, 102, 23, 21, 15, 14, 13, 12, 11, 10) = 1

It should be apparent, then, that the digit-count for a particular digit starts at 1 and gets gradually higher. The rate at which the digit-count increases is highest for 1 and lowest for 0, with digits 2, 3, 4, 5… in between:

All-Base Graph

Graph for digcount(n,dig=d,b=2..n)


You could think of the graph as a digital rodeo in which these digits compete with each other. 1 is the clear and permanent winner, 0 the gradual loser. Now recall the procedure introduced at the start: n = n + digcount(n,dig=d,b=2..n). When it’s applied to the digits 0 to 5, these are the sequences that appear:

n = n + digcount(n,dig=0,b=2..n)

2, 3, 4, 7, 8, 13, 15, 18, 27, 34, 42, 51, 59, 62, 66, 80, 94, 99, 111, 117, 125, 132, 151, 158, 163, 173, 180, 204, 222, 232, 244, 258, 279, 292, 307, 317, 324, 351, 364, 382, 389, 400, 425, 437, 447, 454, 466, 475, 483, 494, 509, 517, 536, 553, 566, 576, 612, 637, 649, 669, 679, 693, 712, 728, 753, 768, 801, 822, 835, 849, 862, 869, 883, 895, 906, 923, 932, 943, 949, 957, 967, 975, 999, 1011…

n = n + digcount(n,dig=1,b=2..n)

2, 3, 6, 12, 23, 44, 75, 124, 202, 319, 503, 780, 1196, 1824, 2766, 4191, 6338, 9546, 14383, 21656, 32562, 48930, 73494, 110361, 165714, 248733, 373303, 560214, 840602, 1261237, 1892269, 2838926, 4258966, 6389157, 9584585, 14377879…

n = n + digcount(n,dig=2,b=2..n)

5, 6, 8, 12, 16, 22, 31, 37, 48, 60, 76, 94, 115, 138, 173, 213, 257, 311, 374, 454, 542, 664, 790, 935, 1109, 1310, 1552, 1835, 2167, 2548, 2989, 3509, 4120, 4832, 5690, 6687, 7829, 9166, 10727, 12568, 14697, 17182, 20089, 23470, 27425, 32042, 37477, 43768, 51113, 59687, 69705, 81379, 94998, 110910, 129488, 151153, 176429, 205923, 240331, 280490, 327396, 382067, 445858…

n = n + digcount(n,dig=3,b=2..n)

7, 8, 9, 10, 11, 13, 16, 18, 22, 25, 29, 34, 38, 44, 50, 56, 63, 80, 90, 104, 113, 131, 151, 169, 188, 210, 236, 261, 289, 320, 350, 385, 424, 463, 520, 572, 626, 684, 747, 828, 917, 999, 1101, 1210, 1325, 1446, 1577, 1716, 1871, 2040, 2228, 2429, 2642, 2875, 3133, 3413, 3719, 4044, 4402, 4786, 5196, 5645, 6140, 6673, 7257, 7900, 8582, 9315, 10130, 10998, 11942, 12954, 14058…

n = n + digcount(n,dig=4,b=2..n)

9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 25, 28, 34, 41, 44, 52, 61, 67, 74, 85, 92, 102, 113, 121, 134, 148, 170, 184, 208, 229, 253, 269, 287, 306, 324, 356, 386, 410, 439, 469, 501, 531, 565, 604, 662, 703, 742, 794, 845, 895, 953, 1007, 1062, 1127, 1188, 1262, 1336, 1421, 1503, 1585, 1676, 1777, 1876, 2001, 2104, 2249, 2375, 2502, 2636, 2789, 2938, 3102, 3267, 3444, 3644, 3868, 4099…

n = n + digcount(n,dig=5,b=2..n)

11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 26, 28, 29, 33, 37, 41, 48, 50, 55, 60, 64, 67, 72, 75, 83, 91, 96, 102, 107, 118, 123, 129, 137, 151, 159, 171, 180, 192, 202, 211, 224, 233, 251, 268, 280, 296, 310, 324, 338, 355, 380, 401, 430, 455, 488, 511, 536, 562, 584, 607, 638, 664, 692, 718, 748, 778, 807, 838, 874, 911, 951, 993, 1039, 1081, 1124, 1166, 1216, 1264, 1313, 1370, 1432…

Shareway to Seven

An adaptation of an interesting distribution puzzle from Joseph Degrazia’s Math is Fun (1954):

After a successful year of plunder on the high seas, a pirate ship returns to its island base. The pirate chief, who enjoys practical jokes and has a mathematical bent, hands out heavy bags of gold coins to his seven lieutenants. But when the seven lieutenants open the bags, they discover that each of them has received a different number of coins.

They ask the captain why they don’t have equal shares. The pirate chief laughs and tells them to re-distribute the coins according to the following rule: “At each stage, the lieutenant with most coins must give each of his comrades as many coins as that comrade already possesses.”

The lieutenants follow the rule and each one in turn becomes the lieutenant with most coins. When the seventh distribution is over, all seven of them have 128 coins, the coins are fairly distributed, and the rule no longer applies.

The puzzle is this: How did the pirate captain originally allocate the coins to his lieutenants?


If you start at the beginning and work forward, you’ll have to solve a fiendishly complicated set of simultaneous equations. If you start at the end and work backwards, the puzzle will resolve itself almost like magic.

The puzzle is actually about powers of 2, because 128 = 2^7 and when each of six lieutenants receives as many coins as he already has, he doubles his number of coins. Accordingly, before the seventh and final distribution, six of the lieutenants must have had 64 coins and the seventh must have had 128 + 6 * 64 coins = 512 coins.

At the stage before that, five of the lieutenants must have had 32 coins (so that they will have 64 coins after the sixth distribution), one must have had 256 coins (so that he will have 512 coins after the sixth distribution), and one must have had 64 + 5 * 32 + 256 coins = 480 coins. And so on. This is what the solution looks like:

128, 128, 128, 128, 128, 128, 128
512, 64, 64, 64, 64, 64, 64
256, 480, 32, 32, 32, 32, 32
128, 240, 464, 16, 16, 16, 16
64, 120, 232, 456, 8, 8, 8
32, 60, 116, 228, 452, 4, 4
16, 30, 58, 114, 226, 450, 2
8, 15, 29, 57, 113, 225, 449

So the pirate captain must have originally allocated the coins like this: 8, 15, 29, 57, 113, 225, 449 (note how 8 * 2 – 1 = 15, 15 * 2 – 1 = 29, 29 * 2 – 1 = 57…).

The puzzle can be adapted to other powers. Suppose the rule runs like this: “At each stage, the lieutenant with most coins must give each of his comrades twice as many coins as that comrade already possesses.” If the pirate captain has six lieutenants, after each distribution each of five will have n + 2n = three times the number of coins that he previously possessed. The six lieutenants each end up with 729 coins = 3^6 coins and the solution looks like this:

13, 37, 109, 325, 973, 2917
39, 111, 327, 975, 2919, 3
117, 333, 981, 2925, 9, 9
351, 999, 2943, 27, 27, 27
1053, 2997, 81, 81, 81, 81
3159, 243, 243, 243, 243, 243
729, 729, 729, 729, 729, 729

For powers of 4, the rule runs like this: “At each stage, the lieutenant with most coins must give each of his comrades three times as many coins as that comrade already possesses.” With five lieutenants, each of them ends up with 1024 coins = 4^5 coins and the solution looks like this:

16, 61, 241, 961, 3841
64, 244, 964, 3844, 4
256, 976, 3856, 16, 16
1024, 3904, 64, 64, 64
4096, 256, 256, 256, 256
1024, 1024, 1024, 1024, 1024

For powers of 5, the rule runs like this: “At each stage, the lieutenant with most coins must give each of his comrades four times as many coins as that comrade already possesses.” With four lieutenants, each of them ends up with 625 coins = 5^4 coins and the solution looks like this:

17, 81, 401, 2001
85, 405, 2005, 5
425, 2025, 25, 25
2125, 125, 125, 125
625, 625, 625, 625