Reciprocal Recipes

Here’s a sequence. What’s the next number?

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...

Here’s another sequence. What’s the next number?

0, 1, 1, 2, 3, 5, 8, 13, 21, 34...

Those aren’t trick questions, so the answers are 1 and 55, respectively. The second sequence is the famous Fibonacci sequence, where each number after [0,1] is the sum of the previous two numbers.

Now try dividing each of those sequences by powers of 2 and summing the results, like this:

1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64 + 1/128 + 1/256 + 1/512 + 1/1024 + 1/2048 + 1/4096 + 1/8192 + 1/16384 + 1/32768 + 1/65536 + 1/131072 + 1/262144 + 1/524288 + 1/1048576 +... = ?

0/2 + 1/4 + 1/8 + 2/16 + 3/32 + 5/64 + 8/128 + 13/256 + 21/512 + 34/1024 + 55/2048 + 89/4096 + 144/8192 + 233/16384 + 377/32768 + 610/65536 + 987/131072 + 1597/262144 + 2584/524288 + 4181/1048576 +... = ?

What are the sums? I was surprised to learn that they’re identical:

1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64 + 1/128 + 1/256 + 1/512 + 1/1024 + 1/2048 + 1/4096 + 1/8192 + 1/16384 + 1/32768 + 1/65536 + 1/131072 + 1/262144 + 1/524288 + 1/1048576 +... = 1

0/2 + 1/4 + 1/8 + 2/16 + 3/32 + 5/64 + 8/128 + 13/256 + 21/512 + 34/1024 + 55/2048 + 89/4096 + 144/8192 + 233/16384 + 377/32768 + 610/65536 + 987/131072 + 1597/262144 + 2584/524288 + 4181/1048576 +... = 1

I discovered this when I was playing with an old scientific calculator and calculated these sums:

5^2 + 2^2 = 29
5^2 + 4^2 = 41
5^2 + 6^2 = 61
5^2 + 8^2 = 89

The sums are all prime numbers. Then I idly calculated the reciprocal of 1/89:

1/89 = 0·011235955056179775...

The digits 011235… are the start of the Fibonacci sequence. It seems to go awry after that, but I remembered what David Wells had said in his wonderful Penguin Dictionary of Curious and Interesting Numbers (1986): “89 is the 11th Fibonacci number, and the period of its reciprocal is generated by the Fibonacci sequence: 1/89 = 0·11235…” He means that the Fibonacci sequence generates the digits of 1/89 like this, when you sum the columns and move carries left as necessary:

0
1
↓↓1
↓↓↓2
↓↓↓↓3
↓↓↓↓↓5
↓↓↓↓↓↓8
↓↓↓↓↓↓13
↓↓↓↓↓↓↓21
↓↓↓↓↓↓↓↓34
↓↓↓↓↓↓↓↓↓55
↓↓↓↓↓↓↓↓↓↓89...
↓↓↓↓↓↓↓↓↓↓
0112359550...

I tried this method of summing the Fibonacci sequence in other bases. Although it was old, the scientific calculator was crudely programmable. And it helpfully converted the sum into a final fraction once there were enough decimal digits:

0/3 + 1/32 + 1/33 + 2/34 + 3/35 + 5/36 + 8/37 + 13/38 + 21/39 + 34/310 + 55/311 + 89/312 + 144/313 + 233/314 + 377/315 + 610/316 + 987/317 + 1597/318 + 2584/319 + 4181/320 +... = 1/5 = 0·012101210121012101210 in b3

0/4 + 1/42 + 1/43 + 2/44 + 3/45 + 5/46 + 8/47 + 13/48 + 21/49 + 34/410 + 55/411 + 89/412 + 144/413 + 233/414 + 377/415 + 610/416 + 987/417 + 1597/418 + 2584/419 + 4181/420 +... = 1/11 = 0·011310113101131011310 in b4

0/5 + 1/52 + 1/53 + 2/54 + 3/55 + 5/56 + 8/57 + 13/58 + 21/59 + 34/510 + 55/511 + 89/512 + 144/513 + 233/514 + 377/515 + 610/516 + 987/517 + 1597/518 + 2584/519 + 4181/520 +... = 1/19 = 0·011242141011242141011 in b5

0/6 + 1/62 + 1/63 + 2/64 + 3/65 + 5/66 + 8/67 + 13/68 + 21/69 + 34/610 + 55/611 + 89/612 + 144/613 + 233/614 + 377/615 + 610/616 + 987/617 + 1597/618 + 2584/619 + 4181/620 +... = 1/29 = 0·011240454431510112404 in b6

0/7 + 1/72 + 1/73 + 2/74 + 3/75 + 5/76 + 8/77 + 13/78 + 21/79 + 34/710 + 55/711 + 89/712 + 144/713 + 233/714 + 377/715 + 610/716 + 987/717 + 1597/718 + 2584/719 + 4181/720 +... = 1/41 = 0·011236326213520225056 in b7

It was interesting to see that all the reciprocals so far were of primes. I carried on:

0/8 + 1/82 + 1/83 + 2/84 + 3/85 + 5/86 + 8/87 + 13/88 + 21/89 + 34/810 + 55/811 + 89/812 + 144/813 + 233/814 + 377/815 + 610/816 + 987/817 + 1597/818 + 2584/819 + 4181/820 +... = 1/55 = 0·011236202247440451710 in b8

Not a prime reciprocal, but a reciprocal of a Fibonacci number. Here are some more sums:

0/9 + 1/92 + 1/93 + 2/94 + 3/95 + 5/96 + 8/97 + 13/98 + 21/99 + 34/910 + 55/911 + 89/912 + 144/913 + 233/914 + 377/915 + 610/916 + 987/917 + 1597/918 + 2584/919 + 4181/920 +... = 1/71 (another prime) = 0·011236067540450563033 in b9

0/10 + 1/102 + 1/103 + 2/104 + 3/105 + 5/106 + 8/107 + 13/108 + 21/109 + 34/1010 + 55/1011 + 89/1012 + 144/1013 + 233/1014 + 377/1015 + 610/1016 + 987/1017 + 1597/1018 + 2584/1019 + 4181/1020 +... = 1/89 (and another) = 0·011235955056179775280 in b10

0/11 + 1/112 + 1/113 + 2/114 + 3/115 + 5/116 + 8/117 + 13/118 + 21/119 + 34/1110 + 55/1111 + 89/1112 + 144/1113 + 233/1114 + 377/1115 + 610/1116 + 987/1117 + 1597/1118 + 2584/1119 + 4181/1120 +... = 1/109 (and another) = 0·011235942695392022470 in b11

0/12 + 1/122 + 1/123 + 2/124 + 3/125 + 5/126 + 8/127 + 13/128 + 21/129 + 34/1210 + 55/1211 + 89/1212 + 144/1213 + 233/1214 + 377/1215 + 610/1216 + 987/1217 + 1597/1218 + 2584/1219 + 4181/1220 +... = 1/131 (and another) = 0·011235930336A53909A87 in b12

0/13 + 1/132 + 1/133 + 2/134 + 3/135 + 5/136 + 8/137 + 13/138 + 21/139 + 34/1310 + 55/1311 + 89/1312 + 144/1313 + 233/1314 + 377/1315 + 610/1316 + 987/1317 + 1597/1318 + 2584/1319 + 4181/1320 +... = 1/155 (not a prime or a Fibonacci number) = 0·01123591ACAA861794044 in b13

The reciprocals go like this:

1/1, 1/5, 1/11, 1/19, 1/29, 1/41, 1/55, 1/71, 1/89, 1/109, 1/131, 1/155...

And it should be easy to see the rule that generates them:

5 = 1 + 4
11 = 5 + 6
19 = 11 + 8
29 = 19 + 10
41 = 29 + 12
55 = 41 + 14
71 = 55 + 16
89 = 17 + 18
109 = 89 + 20
131 = 109 + 22
155 = 131 + 24
[...]

But I don’t understand why the rule applies, let alone why the Fibonacci sequence generates these reciprocals in the first place.

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
[...]

The Viscount of Bi-Count

Today is 22/2/22 and, as I hoped on 2/2/22, I can say more about an interesting little palindromic-pattern problem. For each set of integers <= 1[0]1 in base 10, I looked at the count of palindromes exactly divisible by 1, 2, 3, 4, 5, 6, 7, 8 and 9. For example, 2, 4, 6 and 8 are the 4 palindromes divisible by 2 that are less than 11, so countdiv(2) = 4 for pal <= 11; 3, 6 and 9 are the 3 palindromes divisible by 3, so countdiv(3) = 3; and so on. Here are the counts — and some interesting patterns — for palindromes <= (powers-of-10 + 1) up to 1,000,000,000,001:

count for palindromes <= 101 (prime)

countdiv(1) = 19
countdiv(2) = 8
countdiv(3) = 6
countdiv(4) = 4
countdiv(5) = 2
countdiv(6) = 2
countdiv(7) = 2
countdiv(8) = 2
countdiv(9) = 2

count for palindromes <= 1001 = 7 * 11 * 13

countdiv(1) = 109
countdiv(2) = 48
countdiv(3) = 36
countdiv(4) = 24
countdiv(5) = 12
countdiv(6) = 15
countdiv(7) = 15
countdiv(8) = 12
countdiv(9) = 12

count for palindromes <= 10001 = 73 * 137

countdiv(1) = 199
countdiv(2) = 88
countdiv(3) = 66
countdiv(4) = 44
countdiv(5) = 22
countdiv(6) = 28
countdiv(7) = 32
countdiv(8) = 22
countdiv(9) = 22

count for palindromes <= 100001 = 11 * 9091

countdiv(1) = 1099
countdiv(2) = 488
countdiv(3) = 366
countdiv(4) = 244
countdiv(5) = 122
countdiv(6) = 161
countdiv(7) = 163
countdiv(8) = 122
countdiv(9) = 122

count for palindromes <= 1000001 = 101 * 9901

countdiv(1) = 1999
countdiv(2) = 888
countdiv(3) = 666
countdiv(4) = 444
countdiv(5) = 222
countdiv(6) = 294
countdiv(7) = 303
countdiv(8) = 222
countdiv(9) = 222

count for palindromes <= 10000001 = 11 * 909091

countdiv(1) = 10999
countdiv(2) = 4888
countdiv(3) = 3666
countdiv(4) = 2444
countdiv(5) = 1222
countdiv(6) = 1627
countdiv(7) = 1588
countdiv(8) = 1222
countdiv(9) = 1222

count for palindromes <= 100000001 = 17 * 5882353

countdiv(1) = 19999
countdiv(2) = 8888
countdiv(3) = 6666
countdiv(4) = 4444
countdiv(5) = 2222
countdiv(6) = 2960
countdiv(7) = 2878
countdiv(8) = 2222
countdiv(9) = 2222

count for palindromes <= 1000000001 = 7 * 11 * 13 * 19 * 52579

countdiv(1) = 109999
countdiv(2) = 48888
countdiv(3) = 36666
countdiv(4) = 24444
countdiv(5) = 12222
countdiv(6) = 16293
countdiv(7) = 15734
countdiv(8) = 12222
countdiv(9) = 12222

count for palindromes <= 10000000001 = 101 * 3541 * 27961

countdiv(1) = 199999
countdiv(2) = 88888
countdiv(3) = 66666
countdiv(4) = 44444
countdiv(5) = 22222
countdiv(6) = 29626
countdiv(7) = 28783
countdiv(8) = 22222
countdiv(9) = 22222

count for palindromes <= 100000000001 = 11^2 * 23 * 4093 * 8779

countdiv(1) = 1099999
countdiv(2) = 488888
countdiv(3) = 366666
countdiv(4) = 244444
countdiv(5) = 122222
countdiv(6) = 162959
countdiv(7) = 157361
countdiv(8) = 122222
countdiv(9) = 122222

count for palindromes <= 1000000000001 = 73 * 137 * 99990001

countdiv(1) = 1999999
countdiv(2) = 888888
countdiv(3) = 666666
countdiv(4) = 444444
countdiv(5) = 222222
countdiv(6) = 296292
countdiv(7) = 286461
countdiv(8) = 222222
countdiv(9) = 222222

As you can see, the counts for some numbers alternate between rep-digits (all digits the same) and nearly rep-digits. For example, the counts for palindromes exactly divisible by 5, 8 and 9 are alternately all 2s or 1 followed by all 2s. And you get counts of 2, 12, 22, 122, 222, 1222, 2222 in other even bases greater than base 2 when the counts are represented in that base. Here’s base 8:

count for palindromes <= 101 in b8 = 65 in b10 = 5 * 13

countdiv(1) = 17 in b8 (15 in b10)
countdiv(2) = 6
countdiv(3) = 11 in b8 (9)
countdiv(4) = 2
countdiv(5) = 3
countdiv(6) = 4
countdiv(7) = 2

count for palindromes <= 1001 in b8 = 513 in b10 = 3^3 * 19

countdiv(1) = 107 in b8 (71 in b10)
countdiv(2) = 36 in b8 (30)
countdiv(3) = 34 in b8 (28)
countdiv(4) = 12 in b8 (10)
countdiv(5) = 20 in b8 (16)
countdiv(6) = 14 in b8 (12)
countdiv(7) = 12 in b8 (10)

count for palindromes <= 10001 in b8 = 4097 in b10 = 17 * 241

countdiv(1) = 177 in b8 (127 in b10)
countdiv(2) = 66 in b8 (54)
countdiv(3) = 123 in b8 (83)
countdiv(4) = 22 in b8 (18)
countdiv(5) = 34 in b8 (28)
countdiv(6) = 44 in b8 (36)
countdiv(7) = 22 in b8 (18)

count for palindromes <= 100001 in b8 = 32769 in b10 = 3^2 * 11 * 331

countdiv(1) = 1077 in b8 (575 in b10)
countdiv(2) = 366 in b8 (246)
countdiv(3) = 352 in b8 (234)
countdiv(4) = 122 in b8 (82)
countdiv(5) = 164 in b8 (116)
countdiv(6) = 144 in b8 (100)
countdiv(7) = 122 in b8 (82)

count for palindromes <= 1000001 in b8 = 262145 in b10 = 5 * 13 * 37 * 109

countdiv(1) = 1777 in b8 (1023 in b10)
countdiv(2) = 666 in b8 (438)
countdiv(3) = 1251 in b8 (681)
countdiv(4) = 222 in b8 (146)
countdiv(5) = 316 in b8 (206)
countdiv(6) = 444 in b8 (292)
countdiv(7) = 222 in b8 (146)

count for palindromes <= 10000001 in b8 = 2097153 in b10 = 3^2 * 43 * 5419

countdiv(1) = 10777 in b8 (4607 in b10)
countdiv(2) = 3666 in b8 (1974)
countdiv(3) = 3524 in b8 (1876)
countdiv(4) = 1222 in b8 (658)
countdiv(5) = 1645 in b8 (933)
countdiv(6) = 1444 in b8 (804)
countdiv(7) = 1222 in b8 (658)

count for palindromes <= 100000001 in b8 = 16777217 in b10 = 97 * 257 * 673

countdiv(1) = 17777 in b8 (8191 in b10)
countdiv(2) = 6666 in b8 (3510)
countdiv(3) = 12523 in b8 (5459)
countdiv(4) = 2222 in b8 (1170)
countdiv(5) = 3164 in b8 (1652)
countdiv(6) = 4444 in b8 (2340)
countdiv(7) = 2222 in b8 (1170)

The counts for 4-palindromes and 7-palindromes in base 8 run: 1, 12, 22, 122, 222, 1222, 2222…, just like the counts for 5-palindromes, 8-palindromes and 9-palindromes in base 10. Here’s base 14:

count for palindromes <= 101 in b14 = 197 in b10 (prime)

countdiv(1) = 1D in b14 (27 in b10)
countdiv(2) = C in b14 (12)
countdiv(3) = 13 in b14 (17)
countdiv(4) = 6
countdiv(5) = 11 in b14 (15)
countdiv(6) = 8
countdiv(7) = 2
countdiv(8) = 2
countdiv(9) = 5
countdiv(A) = 7
countdiv(B) = 2
countdiv(C) = 4
countdiv(D) = 2

count for palindromes <= 1001 in b14 = 2745 in b10 = 3^2 * 5 * 61

countdiv(1) = 10D in b14 (209 in b10)
countdiv(2) = 6C in b14 (96)
countdiv(3) = 58 in b14 (78)
countdiv(4) = 36 in b14 (48)
countdiv(5) = 3A in b14 (52)
countdiv(6) = 28 in b14 (36)
countdiv(7) = 12 in b14 (16)
countdiv(8) = 19 in b14 (23)
countdiv(9) = 1C in b14 (26)
countdiv(A) = 19 in b14 (23)
countdiv(B) = 14 in b14 (18)
countdiv(C) = 14 in b14 (18)
countdiv(D) = 12 in b14 (16)

count for palindromes <= 10001 in b14 = 38417 in b10 = 41 * 937

countdiv(1) = 1DD in b14 (391 in b10)
countdiv(2) = CC in b14 (180)
countdiv(3) = 147 in b14 (259)
countdiv(4) = 66 in b14 (90)
countdiv(5) = 129 in b14 (233)
countdiv(6) = 88 in b14 (120)
countdiv(7) = 22 in b14 (30)
countdiv(8) = 31 in b14 (43)
countdiv(9) = 66 in b14 (90)
countdiv(A) = 79 in b14 (107)
countdiv(B) = 26 in b14 (34)
countdiv(C) = 44 in b14 (60)
countdiv(D) = 22 in b14 (30)

count for palindromes <= 100001 in b14 = 537825 in b10 = 3 * 5^2 * 71 * 101

countdiv(1) = 10DD in b14 (2939 in b10)
countdiv(2) = 6CC in b14 (1356)
countdiv(3) = 594 in b14 (1110)
countdiv(4) = 366 in b14 (678)
countdiv(5) = 3B2 in b14 (744)
countdiv(6) = 288 in b14 (512)
countdiv(7) = 122 in b14 (226)
countdiv(8) = 1A1 in b14 (337)
countdiv(9) = 1CA in b14 (374)
countdiv(A) = 1A7 in b14 (343)
countdiv(B) = 150 in b14 (266)
countdiv(C) = 144 in b14 (256)
countdiv(D) = 122 in b14 (226)

count for palindromes <= 1000001 in b14 = 7529537 in b10 = 37 * 197 * 1033

countdiv(1) = 1DDD in b14 (5487 in b10)
countdiv(2) = CCC in b14 (2532)
countdiv(3) = 1493 in b14 (3657)
countdiv(4) = 666 in b14 (1266)
countdiv(5) = 12B1 in b14 (3291)
countdiv(6) = 888 in b14 (1688)
countdiv(7) = 222 in b14 (422)
countdiv(8) = 331 in b14 (631)
countdiv(9) = 63A in b14 (1228)
countdiv(A) = 7A7 in b14 (1519)
countdiv(B) = 278 in b14 (498)
countdiv(C) = 444 in b14 (844)
countdiv(D) = 222 in b14 (422)

count for palindromes <= 10000001 in b14 = 105413505 in b10 = 3 * 5 * 7027567

countdiv(1) = 10DDD in b14 (41159 in b10)
countdiv(2) = 6CCC in b14 (18996)
countdiv(3) = 5948 in b14 (15548)
countdiv(4) = 3666 in b14 (9498)
countdiv(5) = 3B2A in b14 (10426)
countdiv(6) = 2888 in b14 (7176)
countdiv(7) = 1222 in b14 (3166)
countdiv(8) = 1A31 in b14 (4747)
countdiv(9) = 1C6D in b14 (5193)
countdiv(A) = 1A79 in b14 (4811)
countdiv(B) = 1513 in b14 (3741)
countdiv(C) = 1444 in b14 (3588)
countdiv(D) = 1222 in b14 (3166)

count for palindromes <= 100000001 in b14 = 1475789057 in b10 = 17 * 5393 * 16097

countdiv(1) = 1DDDD in b14 (76831 in b10)
countdiv(2) = CCCC in b14 (35460)
countdiv(3) = 14947 in b14 (51219)
countdiv(4) = 6666 in b14 (17730)
countdiv(5) = 12B29 in b14 (46097)
countdiv(6) = 8888 in b14 (23640)
countdiv(7) = 2222 in b14 (5910)
countdiv(8) = 3331 in b14 (8863)
countdiv(9) = 631D in b14 (17079)
countdiv(A) = 7A79 in b14 (21275)
countdiv(B) = 278B in b14 (6983)
countdiv(C) = 4444 in b14 (11820)
countdiv(D) = 2222 in b14 (5910)

Now 7-palindromes and D-palindromes (D = 13 in base 10) are following the [1]2222… pattern. What explains it? If you’re good at math, you won’t need telling. But I’m not good at maths, so I’m going to tell myself and other members of the not-good-at-math community what’s going on. Let’s go back to base 10 and the counts for 5-palindromes, that is, palindromes exactly divisible by 5. In base 10, the only integers exactly divisible by 5 have to end in either 5 or 0. But a palindrome can’t end in 0, because then the leading digit would have to be 0 too. Therefore only palindromes ending in 5 are exactly divisible by 5 in base 10. And if the palindromes end in 5, they have to start with 5 too.

Once we know that, we can easily calculate, for a given number of digits, how many 5-palindromes there are. Take 5-palindromes with three digits. If the three-digit 5-palindromes end and start with 5, we have to consider only the middle digit, which can obviously range from 0 to 9: 505, 515, 525, 535, 545, 555, 565, 575, 585 and 595. So there are 10 3-digit 5-palindromes. We add that count to the count for the single one-digit 5-palindrome, 5, and the single two-digit 5-palindrome, 55. So the cumulative count for 5-palindromes < 1001 is: 10 + 1 + 1 = 12.

Now look at four-digit 5-palindromes. They start and end with 5, therefore we have to consider only the middle two digits. And those middle digits have to be identical: 5005, 5115, 5225, 5335, 5445, 5555, 5665, 5775, 5885, 5995. So there are also 10 four-digit 5-palindromes and count of 5-palindromes < 10001 is: 10 + 10 + 1 + 1 = 22.

Now look at five-digit 5-palindromes. Again we have consider only the middle digits, because the first and fifth digits have to be 5. The second digit of a five-digit 5-palindrome has to be the same as the fourth digit: 50005, 51715, 52425, 53135, and so on. And the second and fourth digits can obviously range from 0 to 9. And so can the third and middle digit of the 5-palindromes. But the third digit doesn’t have to be the same as the second and fourth digits: 50005, 50105, 50205, and so on. Therefore the number of five-digit 5-palindromes is 10 * 10 = 100. And the count of 5-palindromes < 100001 is: 100 + 10 + 10 + 1 + 1 = 122.

Now look at six-digit 5-palindromes. The second digit of a six-digit 5-palindrome has to be same as the fifth digit and the third digit has to be the same as the fourth digit. So once you have the second and third digits, you automatically have the fourth and fifth digits: 500005, 523325, 587785, and so on. Clearly, the second and third digits range from 00 to 99 (i.e., 00, 01, 02 … 97, 98, 99), so there must be 100 six-digit 6-palindromes. And the count of 5-palindromes < 1000001 is: 100 + 100 + 10 + 10 + 1 + 1 = 222.

It should be clear, then, that the count of 5-palindromes for an odd number of digits, d, will be always the same as the count of 5-palindromes for the even number of digits d+1. There is 1 one-digit 5-palindrome, namely 5, and 1 two-digit 5-palindrome, namely 55. There are 10 three-digit 5-palindromes, 505 to 595, and 10 four-digit 5-palindromes, 5005 to 5995. Now, the count of 5-palindromes with an odd number of digits, d, will be equal to 10^(d\2), where d\2 = (d-1)/2. And the count for 5-palindromes with the even number of digits d+1 will be the same, 10^(d\2). Therefore the count for both sets of 5-palindromes, d-digit palindromes and (d+1)-digit palindromes, will be 2 * 10^(d\2). And that’s why the cumulative count of 5-palindromes looks the way it does in base 10: 1, 2, 12, 22, 122, 222, 1222, 2222, 12222, 22222…

The same reasoning applies in other even bases greater than base 2. When a palindrome divisible by a particular number has to start and end with the same digit, s, in base b, the middle digits will dictate a count of b^(d\2) for both d-digit s-palindromes and (d+1)-digit s-palindromes. And you’ll get the same cumulative count for s-palindromes in that base: 1, 2, 12, 22, 122, 222, 1222, 2222, 12222, 22222…

Some other patterns in the palindrome-counts can be explained by extending the reasoning given above. For example, if an s-palindrome can begin and end with two possible numbers, you’ll get cumulative counts of 2, 4, 24, 44, 244, 444, 2444, 4444, 24444, 44444 and so on. If the s-palindrome can end with three possible numbers, you’ll get cumulative counts of 3, 6, 36, 66, 366, 666, 3666, 6666, 36666, 66666 and so on.

Post-Performative Post-Scriptum

The discussion above is of very simple mathematics, but that’s the only kind I can cope with. All the same, I’m pleased that I managed to work out why the count of 5-palindromes behaves like that in base 10. So I’ve decided to award myself a title. Remember that the count for 5-palindromes of length d and d+1 is 2 * 10^(d\2), where d is an odd number. And you could say that 2 * 10^(d\2) is a bi-count of 10^(d\2). So I’m calling myself the Viscount of Bi-Count.

Fib and Let Tri

It’s a simple sequence with hidden depths:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155... — A000045 at OEIS

That’s the Fibonacci sequence, probably the most famous of all integer sequences after the integers themselves (1, 2, 3, 4, 5…) and the primes (2, 3, 5, 7, 11…). It has a very simple definition: if fib(fi) is the fi-th number in the Fibonacci sequence, then fib(fi) = fib(fi-1) + fib(fi-2). By definition, fib(1) = fib(2) = 1. After that, it’s easy to generate new numbers:

2 = fib(3) = fib(1) + fib(2) = 1 + 1
3 = fib(4) = fib(2) + fib(3) = 1 + 2
5 = fib(5) = fib(3) + fib(4) = 2 + 3
8 = fib(6) = fib(4) + fib(5) = 3 + 5
13 = fib(7) = fib(5) + fib(6) = 5 + 8
21 = fib(8) = fib(6) + fib(7) = 8 + 13
34 = fib(9) = fib(7) + fib(8) = 13 + 21
55 = fib(10) = fib(8) + fib(9) = 21 + 34
89 = fib(11) = fib(9) + fib(10) = 34 + 55
144 = fib(12) = fib(10) + fib(11) = 55 + 89
233 = fib(13) = fib(11) + fib(12) = 89 + 144
377 = fib(14) = fib(12) + fib(13) = 144 + 233
610 = fib(15) = fib(13) + fib(14) = 233 + 377
987 = fib(16) = fib(14) + fib(15) = 377 + 610
[...]

How to create the Fibonacci sequence is obvious. But it’s not obvious that fib(fi) / fib(fi-1) gives you ever-better approximations to a fascinating constant called φ, the golden ratio, which is 1.618033988749894…:

1/1 = 1
2/1 = 2
3/2 = 1.5
5/3 = 1.66666...
8/5 = 1.6
13/8 = 1.625
21/13 = 1.615384...
34/21 = 1.619047...
55/34 = 1.6176470588235294117647058823...
89/55 = 1.618181818...
144/89 = 1.617977528089887640...
233/144 = 1.6180555555...
377/233 = 1.618025751072961...
610/377 = 1.618037135278514...
987/610 = 1.618032786885245...
[...]

And that’s just the start of the hidden depths in the Fibonacci sequence. I stumbled across another interesting pattern for myself a few days ago. I was looking at the sequence and one of the numbers caught my eye:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597...

55 is a palindrome, reading the same forward and backwards. I wondered whether there were any other palindromes in the sequence (apart from the trivial single-digit palindromes 1, 1, 2, 3…). I couldn’t find any more. Nor can anyone else, apparently. But that’s in base 10. Other bases are more productive. For example, in bases 2, 3 and 4, you get this:

11 in b2 = 3
101 in b2 = 5
10101 in b2 = 21

22 in b3 = 8
111 in b3 = 13
22122 in b3 = 233

11 in b4 = 5
111 in b4 = 21
202 in b4 = 34
313 in b4 = 55

I decided to concentrate on tripals, or palindromes with three digits. I started looking at bases that set records for the greatest number of tripals. And there are some interesting patterns in the digits of the tripals in these bases (when a digit > 9, the digit is represented inside square brackets — see base-29 and higher). See how quickly you can spot the patterns:

Palindromic Fibonacci numbers in base-4

111 in b4 (fib=21, fi=8)
202 in b4 (fib=34, fi=9)
313 in b4 (fib=55, fi=10)

4 = 2^2 (pal=3)

Palindromic Fibonacci numbers in base-11

121 in b11 (fib=144, fi=12)
313 in b11 (fib=377, fi=14)
505 in b11 (fib=610, fi=15)
818 in b11 (fib=987, fi=16)

11 is prime (pal=4)

Palindromic Fibonacci numbers in base-29

151 in b29 (fib=987, fi=16)
323 in b29 (fib=2584, fi=18)
818 in b29 (fib=6765, fi=20)
[13]0[13] in b29 (fib=10946, fi=21)
[21]1[21] in b29 (fib=17711, fi=22)

29 is prime (pal=5)

Palindromic Fibonacci numbers in base-76

1[13]1 in b76 (fib=6765, fi=20)
353 in b76 (fib=17711, fi=22)
828 in b76 (fib=46368, fi=24)
[21]1[21] in b76 (fib=121393, fi=26)
[34]0[34] in b76 (fib=196418, fi=27)
[55]1[55] in b76 (fib=317811, fi=28)

76 = 2^2 * 19 (pal=6)

Palindromic Fibonacci numbers in base-199

1[34]1 in b199 (fib=46368, fi=24)
3[13]3 in b199 (fib=121393, fi=26)
858 in b199 (fib=317811, fi=28)
[21]2[21] in b199 (fib=832040, fi=30)
[55]1[55] in b199 (fib=2178309, fi=32)
[89]0[89] in b199 (fib=3524578, fi=33)
[144]1[144] in b199 (fib=5702887, fi=34)

199 is prime (pal=7)

Palindromic Fibonacci numbers in base-521

1[89]1 in b521 (fib=317811, fi=28)
3[34]3 in b521 (fib=832040, fi=30)
8[13]8 in b521 (fib=2178309, fi=32)
[21]5[21] in b521 (fib=5702887, fi=34)
[55]2[55] in b521 (fib=14930352, fi=36)
[144]1[144] in b521 (fib=39088169, fi=38)
[233]0[233] in b521 (fib=63245986, fi=39)
[377]1[377] in b521 (fib=102334155, fi=40)

521 is prime (pal=8)

Palindromic Fibonacci numbers in base-1364

1[233]1 in b1364 (fib=2178309, fi=32)
3[89]3 in b1364 (fib=5702887, fi=34)
8[34]8 in b1364 (fib=14930352, fi=36)
[21][13][21] in b1364 (fib=39088169, fi=38)
[55]5[55] in b1364 (fib=102334155, fi=40)
[144]2[144] in b1364 (fib=267914296, fi=42)
[377]1[377] in b1364 (fib=701408733, fi=44)
[610]0[610] in b1364 (fib=1134903170, fi=45)
[987]1[987] in b1364 (fib=1836311903, fi=46)

1364 = 2^2 * 11 * 31 (pal=9)

Two patterns are quickly obvious. Every digit in the tripals is a Fibonacci number. And the middle digit of one Fibonacci tripal, fib(fi), becomes fib(fi-2) in the next tripal, while fib(fi), the first and last digits (which are identical), becomes fib(fi+2) in the next tripal.

But what about the bases? If you’re an expert in the Fibonacci sequence, you’ll spot the pattern at work straight away. I’m not an expert, but I spotted it in the end. Here are the first few bases setting records for the numbers of Fibonacci tripals:

4, 11, 29, 76, 199, 521, 1364, 3571, 9349, 24476, 64079, 167761, 439204, 1149851, 3010349, 7881196...

These numbers come from the Lucas sequence, which is closely related to the Fibonacci sequence. But where fib(1) = fib(2) = 1, luc(1) = 1 and luc(2) = 3. After that, luc(li) = luc(li-2) + luc(li-1):

1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196... — A000204 at OEIS

It seems that every second number from 4 in the Lucas sequence supplies a base in which 1) the number of Fibonacci tripals sets a new record; 2) every digit of the Fibonacci tripals is itself a Fibonacci number.

But can I prove that this is always true? No. And do I understand why these patterns exist? No. My simple search for palindromes in the Fibonacci sequence soon took me far out of my mathematical depth. But it’s been fun to find huge bases like this in which every digit of every Fibonacci tripal is itself a Fibonacci number:

Palindromic Fibonacci numbers in base-817138163596

1[139583862445]1 in b817138163596 (fib=781774079430987230203437, fi=116)
3[53316291173]3 in b817138163596 (fib=2046711111473984623691759, fi=118)
8[20365011074]8 in b817138163596 (fib=5358359254990966640871840, fi=120)
[21][7778742049][21] in b817138163596 (fib=14028366653498915298923761, fi=122)
[55][2971215073][55] in b817138163596 (fib=36726740705505779255899443, fi=124)
[144][1134903170][144] in b817138163596 (fib=96151855463018422468774568, fi=126)
[377][433494437][377] in b817138163596 (fib=251728825683549488150424261, fi=128)
[987][165580141][987] in b817138163596 (fib=659034621587630041982498215, fi=130)
[2584][63245986][2584] in b817138163596 (fib=1725375039079340637797070384, fi=132)
[6765][24157817][6765] in b817138163596 (fib=4517090495650391871408712937, fi=134)
[17711][9227465][17711] in b817138163596 (fib=11825896447871834976429068427, fi=136)
[46368][3524578][46368] in b817138163596 (fib=30960598847965113057878492344, fi=138)
[121393][1346269][121393] in b817138163596 (fib=81055900096023504197206408605, fi=140)
[317811][514229][317811] in b817138163596 (fib=212207101440105399533740733471, fi=142)
[832040][196418][832040] in b817138163596 (fib=555565404224292694404015791808, fi=144)
[2178309][75025][2178309] in b817138163596 (fib=1454489111232772683678306641953, fi=146)
[5702887][28657][5702887] in b817138163596 (fib=3807901929474025356630904134051, fi=148)
[14930352][10946][14930352] in b817138163596 (fib=9969216677189303386214405760200, fi=150)
[39088169][4181][39088169] in b817138163596 (fib=26099748102093884802012313146549, fi=152)
[102334155][1597][102334155] in b817138163596 (fib=68330027629092351019822533679447, fi=154)
[267914296][610][267914296] in b817138163596 (fib=178890334785183168257455287891792, fi=156)
[701408733][233][701408733] in b817138163596 (fib=468340976726457153752543329995929, fi=158)
[1836311903][89][1836311903] in b817138163596 (fib=1226132595394188293000174702095995, fi=160)
[4807526976][34][4807526976] in b817138163596 (fib=3210056809456107725247980776292056, fi=162)
[12586269025][13][12586269025] in b817138163596 (fib=8404037832974134882743767626780173, fi=164)
[32951280099]5[32951280099] in b817138163596 (fib=22002056689466296922983322104048463, fi=166)
[86267571272]2[86267571272] in b817138163596 (fib=57602132235424755886206198685365216, fi=168)
[225851433717]1[225851433717] in b817138163596 (fib=150804340016807970735635273952047185, fi=170)
[365435296162]0[365435296162] in b817138163596 (fib=244006547798191185585064349218729154, fi=171)
[591286729879]1[591286729879] in b817138163596 (fib=394810887814999156320699623170776339, fi=172)

817138163596 = 2^2 * 229 * 9349 * 95419 (pal=30)

Palindrought

The alchemists dreamed of turning dross into gold. In mathematics, you can actually do that, metaphorically speaking. If palindromes are gold and non-palindromes are dross, here is dross turning into gold:

22 = 10 + 12
222 = 10 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 23 + 24
484 = 10 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 34
555 = 10 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 34 + 35 + 36
2002 = nonpalsum(10,67)
36863 = nonpalsum(10,286)
45954 = nonpalsum(10,319)
80908 = nonpalsum(10,423)
113311 = nonpalsum(10,501)
161161 = nonpalsum(10,598)
949949 = nonpalsum(10,1417)
8422248 = nonpalsum(10,4136)
13022031 = nonpalsum(10,5138)
14166141 = nonpalsum(10,5358)
16644661 = nonpalsum(10,5806)
49900994 = nonpalsum(10,10045)
464939464 = nonpalsum(10,30649)
523434325 = nonpalsum(10,32519)
576656675 = nonpalsum(10,34132)
602959206 = nonpalsum(10,34902)
[...]

The palindromes don’t seem to stop arriving. But something unexpected happens when you try to turn gold into gold. If you sum palindromes to get palindromes, you’re soon hit by what you might call a palindrought, where no palindromes appear:

1 = 1
3 = 1 + 2
6 = 1 + 2 + 3
111 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 11 + 22 + 33
353 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 11 + 22 + 33 + 44 + 55 + 66 + 77
7557 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 101 + 111 + 121 + 131 + 141 + 151 + 161 + 171 + 181 + 191 + 202 + 212 + 222 + 232 + 242 + 252 + 262 + 272 + 282 + 292 + 303 + 313 + 323 + 333 + 343 + 353 + 363 + 373 + 383
2376732 = palsum(1,21512)

That’s sequence A046488 at the OEIS. And I suspect that the sequence is complete and that the palindrought never ends. For some evidence of that, here’s an interesting pattern that emerges if you look at palsums of 1 to repdigits 9[…]9:

50045040 = palsum(1,99999)
50045045040 = palsum(1,9999999)
50045045045040 = palsum(1,999999999)
50045045045045040 = palsum(1,99999999999)
50045045045045045040 = palsum(1,9999999999999)
50045045045045045045040 = palsum(1,999999999999999)
50045045045045045045045040 = palsum(1,99999999999999999)
50045045045045045045045045040 = palsum(1,9999999999999999999)
50045045045045045045045045045040 = palsum(1,999999999999999999999)

As the sums get bigger, the carries will stop sweeping long enough and the sums may fall into semi-regular patterns of non-palindromic numbers like 50045040. If you try higher bases like base 909, you get more palindromes by summing palindromes, but a palindrought arrives in the end there too:

1 = palsum(1)
3 = palsum(1,2)
6 = palsum(1,3)
A = palsum(1,4)
[...]
66 = palsum(1,[104]) (palindromes = 43)
LL = palsum(1,[195]) (44)
[37][37] = palsum(1,[259]) (45)
[73][73] = palsum(1,[364]) (46)
[114][114] = palsum(1,[455]) (47)
[172][172] = palsum(1,[559]) (48)
[369][369] = palsum(1,[819]) (49)
6[466]6 = palsum(1,[104][104]) (50)
L[496]L = palsum(1,[195][195]) (51)
[37][528][37] = palsum(1,[259][259]) (52)
[73][600][73] = palsum(1,[364][364]) (53)
[114][682][114] = palsum(1,[455][455]) (54)
[172][798][172] = palsum(1,[559][559]) (55)
[291][126][291] = palsum(1,[726][726]) (56)
[334][212][334] = palsum(1,[778][778]) (57)
[201][774][830][774][201] = palsum(1,[605][707][605]) (58)
[206][708][568][708][206] = palsum(1,[613][115][613]) (59)
[456][456][569][569][456][456] = palsum(1,11[455]11) (60)
22[456][454][456]22 = palsum(1,21012) (61)

Note the palindrome for palsum(1,21012). All odd bases higher than 3 seem to produce a palindrome for 1 to 21012 in that base (21012 in base 5 = 1382 in base 10, 2012 in base 7 = 5154 in base 10, and so on):

2242422 = palsum(1,21012) (base=5)
2253522 = palsum(1,21012) (b=7)
2275722 = palsum(1,21012) (b=11)
2286822 = palsum(1,21012) (b=13)
2297922 = palsum(1,21012) (b=15)
22A8A22 = palsum(1,21012) (b=17)
22B9B22 = palsum(1,21012) (b=19)
22CAC22 = palsum(1,21012) (b=21)
22DBD22 = palsum(1,21012) (b=23)

And here’s another interesting pattern created by summing squares in base 9 (where 17 = 16 in base 10, 40 = 36 in base 10, and so on):

1 = squaresum(1)
5 = squaresum(1,4)
33 = squaresum(1,17)
111 = squaresum(1,40)
122221 = squaresum(1,4840)
123333321 = squaresum(1,503840)
123444444321 = squaresum(1,50483840)
123455555554321 = squaresum(1,5050383840)
123456666666654321 = squaresum(1,505048383840)
123456777777777654321 = squaresum(1,50505038383840)
123456788888888887654321 = squaresum(1,5050504838383840)

Then a palindrought strikes again. But you don’t get a palindrought in the triangular numbers, or numbers created by summing the integers, palindromic and non-palindromic alike:

1 = 1
3 = 1 + 2
6 = 1 + 2 + 3
55 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
66 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11
171 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18
595 = 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
666 = 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
3003 = palsum(1,77)
5995 = palsum(1,109)
8778 = palsum(1,132)
15051 = palsum(1,173)
66066 = palsum(1,363)
617716 = palsum(1,1111)
828828 = palsum(1,1287)
1269621 = palsum(1,1593)
1680861 = palsum(1,1833)
3544453 = palsum(1,2662)
5073705 = palsum(1,3185)
5676765 = palsum(1,3369)
6295926 = palsum(1,3548)
35133153 = palsum(1,8382)
61477416 = palsum(1,11088)
178727871 = palsum(1,18906)
1264114621 = palsum(1,50281)
1634004361 = palsum(1,57166)
5289009825 = palsum(1,102849)
6172882716 = palsum(1,111111)
13953435931 = palsum(1,167053)
16048884061 = palsum(1,179158)
30416261403 = palsum(1,246642)
57003930075 = palsum(1,337650)
58574547585 = palsum(1,342270)
66771917766 = palsum(1,365436)
87350505378 = palsum(1,417972)
[...]

If 617716 = palsum(1,1111) and 6172882716 = palsum(1,111111), what is palsum(1,11111111)? Try it for yourself — there’s an easy formula for the triangular numbers.

Rollercoaster Rules

n += digsum(n). It’s one of my favorite integer sequences — a rollercoaster to infinity. It works like this: you take a number, sum its digits, add the sum to the original number, and repeat:

1 → 2 → 4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77 → 91 → 101 → 103 → 107 → 115 → 122 → 127 → 137 → 148 → 161 → 169 → 185 → 199 → 218 → 229 → 242 → 250 → 257 → 271 → 281 → 292 → 305 → 313 → 320 → 325 → 335 → 346 → 359 → 376 → 392 → 406 → 416 → 427 → 440 → 448 → 464 → 478 → 497 → 517 → 530 → 538 → 554 → 568 → 587 → 607 → 620 → 628 → 644 → 658 → 677 → 697 → 719 → 736 → 752 → 766 → 785 → 805 → 818 → 835 → 851 → 865 → 884 → 904 → 917 → 934 → 950 → 964 → 983 → 1003 → 1007 → 1015 → 1022 → 1027 → 1037 → 1048 → 1061 → 1069 → 1085 → 1099 → 1118 → 1129 → 1142 → 1150 → 1157 → 1171 → 1181 → 1192 → 1205 → ...

I call it a rollercoaster to infinity because the digit-sum constantly rises and falls as n gets bigger and bigger. The most dramatic falls are when n gets one digit longer (except on the first occasion):

... → 8 (digit-sum=8) → 16 (digit-sum=7) → ...
... → 91 (ds=10) → 101 (ds=2) → ...
... → 983 (ds=20) → 1003 (ds=4) → ...
... → 9968 (ds=32) → 10000 (ds=1) → ...
... → 99973 (ds=37) → 100010 (ds=2) → ...
... → 999959 (ds=50) → 1000009 (ds=10) → ...
... → 9999953 (ds=53) → 10000006 (ds=7) → ...
... → 99999976 (ds=67) → 100000043 (ds=8) → ...
... → 999999980 (ds=71) → 1000000051 (ds=7) → ...
... → 9999999962 (ds=80) → 10000000042 (ds=7) → ...
... → 99999999968 (ds=95) → 100000000063 (ds=10) → ...
... → 999999999992 (ds=101) → 1000000000093 (ds=13) → ...

Look at 9968 → 10000, when the digit-sum goes from 32 to 1. That’s only the second time that digsum(n) = 1 in the sequence. Does it happen again? I don’t know.

And here’s something else I don’t know. Suppose you introduce a rule for the rollercoaster of n += digsum(n). You buy a ticket with a number on it: 1, 2, 3, 4, 5… Then you get on the rollercoaster powered by with that number. Now here’s the rule: Your ride on the rollercoaster ends when n += digsum(n) yields a rep-digit, i.e., a number whose digits are all the same. Here are the first few rides on the rollercoaster:

1 → 2 → 4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
2 → 4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
3 → 6 → 12 → 15 → 21 → 24 → 30 → 33
4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
5 → 10 → 11
6 → 12 → 15 → 21 → 24 → 30 → 33
7 → 14 → 19 → 29 → 40 → 44
8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
9 → 18 → 27 → 36 → 45 → 54 → 63 → 72 → 81 → 90 → 99
10 → 11
11 → 13 → 17 → 25 → 32 → 37 → 47 → 58 → 71 → 79 → 95 → 109 → 119 → 130 → 134 → 142 → 149 → 163 → 173 → 184 → 197 → 214 → 221 → 226 → 236 → 247 → 260 → 268 → 284 → 298 → 317 → 328 → 341 → 349 → 365 → 379 → 398 → 418 → 431 → 439 → 455 → 469 → 488 → 508 → 521 → 529 → 545 → 559 → 578 → 598 → 620 → 628 → 644 → 658 → 677 → 697 → 719 → 736 → 752 → 766 → 785 → 805 → 818 → 835 → 851 → 865 → 884 → 904 → 917 → 934 → 950 → 964 → 983 → 1003 → 1007 → 1015 → 1022 → 1027 → 1037 → 1048 → 1061 → 1069 → 1085 → 1099 → 1118 → 1129 → 1142 → 1150 → 1157 → 1171 → 1181 → 1192 → 1205 → 1213 → 1220 → 1225 → 1235 → 1246 → 1259 → 1276 → 1292 → 1306 → 1316 → 1327 → 1340 → 1348 → 1364 → 1378 → 1397 → 1417 → 1430 → 1438 → 1454 → 1468 → 1487 → 1507 → 1520 → 1528 → 1544 → 1558 → 1577 → 1597 → 1619 → 1636 → 1652 → 1666 → 1685 → 1705 → 1718 → 1735 → 1751 → 1765 → 1784 → 1804 → 1817 → 1834 → 1850 → 1864 → 1883 → 1903 → 1916 → 1933 → 1949 → 1972 → 1991 → 2011 → 2015 → 2023 → 2030 → 2035 → 2045 → 2056 → 2069 → 2086 → 2102 → 2107 → 2117 → 2128 → 2141 → 2149 → 2165 → 2179 → 2198 → 2218 → 2231 → 2239 → 2255 → 2269 → 2288 → 2308 → 2321 → 2329 → 2345 → 2359 → 2378 → 2398 → 2420 → 2428 → 2444 → 2458 → 2477 → 2497 → 2519 → 2536 → 2552 → 2566 → 2585 → 2605 → 2618 → 2635 → 2651 → 2665 → 2684 → 2704 → 2717 → 2734 → 2750 → 2764 → 2783 → 2803 → 2816 → 2833 → 2849 → 2872 → 2891 → 2911 → 2924 → 2941 → 2957 → 2980 → 2999 → 3028 → 3041 → 3049 → 3065 → 3079 → 3098 → 3118 → 3131 → 3139 → 3155 → 3169 → 3188 → 3208 → 3221 → 3229 → 3245 → 3259 → 3278 → 3298 → 3320 → 3328 → 3344 → 3358 → 3377 → 3397 → 3419 → 3436 → 3452 → 3466 → 3485 → 3505 → 3518 → 3535 → 3551 → 3565 → 3584 → 3604 → 3617 → 3634 → 3650 → 3664 → 3683 → 3703 → 3716 → 3733 → 3749 → 3772 → 3791 → 3811 → 3824 → 3841 → 3857 → 3880 → 3899 → 3928 → 3950 → 3967 → 3992 → 4015 → 4025 → 4036 → 4049 → 4066 → 4082 → 4096 → 4115 → 4126 → 4139 → 4156 → 4172 → 4186 → 4205 → 4216 → 4229 → 4246 → 4262 → 4276 → 4295 → 4315 → 4328 → 4345 → 4361 → 4375 → 4394 → 4414 → 4427 → 4444

The 11-ticket is much better value than the tickets for 1..10. Bigger numbers behave like this:

1252 → 4444
1253 → 4444
1254 → 888888
1255 → 4444
1256 → 4444
1257 → 888888
1258 → 4444
1259 → 4444
1260 → 9999
1261 → 4444
1262 → 4444
1263 → 888888
1264 → 4444
1265 → 4444
1266 → 888888
1267 → 4444
1268 → 4444
1269 → 9999
1270 → 4444
1271 → 4444
1272 → 888888
1273 → 4444
1274 → 4444

Then all at once, a number-ticket turns golden and the rollercoaster-ride doesn’t end. So far, at least. I’ve tried, but I haven’t been able to find a rep-digit for 3515 and 3529 = 3515+digsum(3515) and so on:

3509 → 4444
3510 → 9999
3511 → 4444
3512 → 4444
3513 → 888888
3514 → 4444
3515 → ?
3516 → 888888
3517 → 4444
3518 → 4444
3519 → 9999
3520 → 4444
3521 → 4444
3522 → 888888
3523 → 4444
3524 → 4444
3525 → 888888
3526 → 4444
3527 → 4444
3528 → 9999
3529 → ?
3530 → 4444
3531 → 888888
3532 → 4444

Does 3515 ever yield a rep-digit for n += digsum(n)? It’s hard to believe it doesn’t, but I’ve no idea how to prove that it does. Except by simply riding the rollercoaster. And if the ride with the 3515-ticket never reaches a rep-digit, the rollercoaster will never let you know. How could it?

But here’s an example in base 23 of how a ticket for n+1 can give you a dramatically longer ride than a ticket for n and n+2:

MI → EEE (524 → 7742)
MJ → EEE (525 → 7742)
MK → 444 (526 → 2212)
ML → 444 (527 → 2212)
MM → MMMMMM (528 → 148035888)
100 → 444 (529 → 2212)
101 → 444 (530 → 2212)
102 → EEE (531 → 7742)
103 → 444 (532 → 2212)
104 → 444 (533 → 2212)
105 → EEE (534 → 7742)
106 → EEE (535 → 7742)
107 → 444 (536 → 2212)
108 → EEE (537 → 7742)
109 → 444 (538 → 2212)
10A → MMMMMM (539 → 148035888)
10B → EEE (540 → 7742)
10C → EEE (541 → 7742)
10D → EEE (542 → 7742)
10E → EEE (543 → 7742)
10F → 444 (544 → 2212)
10G → EEE (545 → 7742)
10H → EEE (546 → 7742)
10I → EEE (547 → 7742)
10J → 444 (548 → 2212)
10K → 444 (549 → 2212)
10L → MMMMMM (550 → 148035888)
10M → EEE (551 → 7742)
110 → EEE (552 → 7742)

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.

Count Amounts

One of my favourite integer sequences is what I call the digit-line. You create it by taking this very familiar integer sequence:

• 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20…

And turning it into this one:

• 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 2, 0… (A033307 in the Online Encyclopedia of Integer Sequences)

You simply chop all numbers into single digits. What could be simpler? Well, creating the digit-line couldn’t be simpler, but it is in fact a very complex object. There are hidden depths in its patterns, as even a brief look will uncover. For example, you can try counting the digits as they appear one-by-one in the line and seeing whether the digit-counts compare. Do the 1s of the digit-line always outnumber the 0s, as you might expect? Yes, they do (unless you start the digit-line 0, 1, 2, 3…). But do the 2s always outnumber the 0s? No: at position 2, there’s a 2, and at position 11 there’s a 0. So that’s one 2 and one 0. Does it happen again? Yes, it happens again at the 222nd digit of the digit-line, as below:

1, 2count=1, 3, 4, 5, 6, 7, 8, 9, 1, 0count=1, 1, 1, 1, 22, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 23, 02, 24, 1, 25, 26, 27, 3, 28, 4, 29, 5, 210, 6, 211, 7, 212, 8, 213, 9, 3, 03, 3, 1, 3, 214, 3, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 4, 04, 4, 1, 4, 215, 4, 3, 4, 4, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 5, 05, 5, 1, 5, 216, 5, 3, 5,4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 6, 06, 6, 1, 6, 217, 6, 3, 6, 4, 6, 5, 6, 6, 6, 7, 6, 8, 6, 9, 7, 07, 7, 1, 7, 218, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 8, 7, 9, 8, 08, 8, 1, 8, 219, 8, 3, 8, 4, 8, 5, 8, 6, 8, 7, 8, 8, 8, 9, 9, 09, 9, 1, 9, 220, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 9, 9, 1, 010, 011, 1, 012, 1, 1, 013, 221, 1, 014, 3, 1, 015, 4, 1, 016, 5, 1, 017, 6, 1, 018, 7, 1, 019, 8, 1, 020, 9, 1, 1, 021

So count(2) = count(0) = 1 at digit 11 of the digit-line in the 0 of what was originally 10. And count(2) = count(0) = 21 @ digit 222 in the 0 of what was originally 110. Is a pattern starting to emerge? Yes, it is. Here are the first few points at which the count(2) = count(0) in the digit-line of base 10:

1 @ 11 in 10
21 @ 222 in 110
321 @ 3333 in 1110
4321 @ 44444 in 11110
54321 @ 555555 in 111110
654321 @ 6666666 in 1111110
7654321 @ 77777777 in 11111110
87654321 @ 888888888 in 111111110
987654321 @ 9999999999 in 1111111110
10987654321 @ 111111111110 in 11111111110
120987654321 @ 1222222222221 in 111111111110
[...]

The count(2) = count(0) = 321 at position 3333 in the digit-line, and 4321 at position 44444, and 54321 at position 555555, and so on. I don’t understand why these patterns occur, but you can predict the count-and-position of 2s and 0s easily until position 9999999999, after which things become more complicated. Related patterns for 2 and 0 occur in all other bases except binary (which doesn’t have a 2 digit). Here’s base 6:

1 @ 11 in 10 (1 @ 7 in 6)
21 @ 222 in 110 (13 @ 86 in 42)
321 @ 3333 in 1110 (121 @ 777 in 258)
4321 @ 44444 in 11110 (985 @ 6220 in 1554)
54321 @ 555555 in 111110 (7465 @ 46655 in 9330)
1054321 @ 11111110 in 1111110 (54121 @ 335922 in 55986)
12054321 @ 122222221 in 11111110 (380713 @ 2351461 in 335922)
132054321 @ 1333333332 in 111111110 (2620201 @ 16124312 in 2015538)
1432054321 @ 14444444443 in 1111111110 (17736745 @ 108839115 in 12093234)
15432054321 @ 155555555554 in 11111111110 (118513705 @ 725594110 in 72559410)
205432054321 @ 2111111111105 in 111111111110 (783641641 @ 4788921137 in 435356466)
2205432054321 @ 22222222222220 in 1111111111110 (5137206313 @ 31345665636 in 2612138802)

And what about comparing other pairs of digits? In fact, the count of all digits except 0 matches infinitely often. To write the numbers 1..9 takes one of each digit (except 0). To write the numbers 1 to 99 takes twenty of each digit (except 0). Here’s the proof:

11, 21, 31, 41, 51, 61, 71, 81, 91, 12, 01, 13, 14, 15, 22, 16, 32, 17, 42, 18, 52, 19, 62, 110, 72, 111, 82, 112, 92, 23, 02, 24, 113, 25, 26, 27, 33, 28, 43, 29, 53, 210, 63, 211, 73, 212, 83, 213, 93, 34, 03, 35, 114, 36, 214, 37, 38, 39, 44, 310, 54, 311, 64, 312, 74, 313, 84, 314, 94, 45, 04, 46, 115, 47, 215, 48, 315, 49, 410, 411, 55, 412, 65, 413, 75, 414, 85, 415, 95, 56, 05, 57, 116, 58, 216, 59, 316, 510, 416, 511, 512, 513, 66, 514, 76, 515, 86, 516, 96, 67, 06, 68, 117, 69, 217, 610, 317, 6
11
, 417, 612, 517, 613, 614, 615, 77, 616, 87, 617, 97, 78, 07, 79, 118, 710, 218, 711, 318, 712, 418, 713, 518, 714, 618, 715, 716, 717, 88, 718, 98, 89, 08, 810, 119, 811, 219, 812, 319, 813, 419, 814, 519, 815, 619, 816, 719, 817, 818, 819, 99, 910, 09, 911, 120, 912, 220, 913, 320, 914, 420, 915, 520, 916, 620, 917, 720, 918, 820, 919, 920

And what about writing 1..999, 1..9999, and so on? If you think about it, for every pair of non-zero digits, d1 and d2, all numbers containing one digit can be matched with a number containing the other. 100 → 200, 111 → 222, 314 → 324, 561189571 → 562289572, and so on. So in counting 1..999, 1..9999, 1..99999, you use the same number of non-zero digits. And once again a pattern emerges:

count(0) = 0; count(1) = 1; count(2) = 1; count(3) = 1; count(4) = 1; count(5) = 1; count(6) = 1; count(7) = 1; count(8) = 1; count(9) = 1 (writing 1..9)
count(0) = 9; count(1) = 20; count(2) = 20; count(3) = 20; count(4) = 20; count(5) = 20; count(6) = 20; count(7) = 20; count(8) = 20; count(9) = 20 (writing 1..99)
0: 189; 1: 300; 2: 300; 3: 300; 4: 300; 5: 300; 6: 300; 7: 300; 8: 300; 9: 300 (writing 1..999)
0: 2889; 1: 4000; 2: 4000; 3: 4000; 4: 4000; 5: 4000; 6: 4000; 7: 4000; 8: 4000; 9: 4000 (writing 1..9999)
0: 38889; 1: 50000; 2: 50000; 3: 50000; 4: 50000; 5: 50000; 6: 50000; 7: 50000; 8: 50000; 9: 50000 (writing 1..99999)
0: 488889; 1: 600000; 2: 600000; 3: 600000; 4: 600000; 5: 600000; 6: 600000; 7: 600000; 8: 600000; 9: 600000 (writing 1..999999)
0: 5888889; 1: 7000000; 2: 7000000; 3: 7000000; 4: 7000000; 5: 7000000; 6: 7000000; 7: 7000000; 8: 7000000; 9: 7000000 (writing 1..9999999)
[...]

And here’s base 6 again:

0: 0; 1: 1; 2: 1; 3: 1; 4: 1; 5: 1 (writing 1..5)
0: 5; 1: 20; 2: 20; 3: 20; 4: 20; 5: 20 (writing 1..55 in base 6)
0: 145; 1: 300; 2: 300; 3: 300; 4: 300; 5: 300 (writing 1..555)
0: 2445; 1: 4000; 2: 4000; 3: 4000; 4: 4000; 5: 4000 (writing 1..5555)
0: 34445; 1: 50000; 2: 50000; 3: 50000; 4: 50000; 5: 50000 (writing 1..55555)
0: 444445; 1: 1000000; 2: 1000000; 3: 1000000; 4: 1000000; 5: 1000000 (writing 1..555555)
0: 5444445; 1: 11000000; 2: 11000000; 3: 11000000; 4: 11000000; 5: 11000000 (writing 1..5555555)
0: 104444445; 1: 120000000; 2: 120000000; 3: 120000000; 4: 120000000; 5: 120000000 (writing 1..55555555)
0: 1144444445; 1: 1300000000; 2: 1300000000; 3: 1300000000; 4: 1300000000; 5: 1300000000 (writing 1..555555555)

Autonomata

“Describe yourself.” You can say it to people. And you can say it to numbers too. For example, here’s the number 3412 describing the positions of its own digits, starting at 1 and working upward:

3412 – the 1 is in the 3rd position, the 2 is in the 4th position, the 3 is in the 1st position, and the 4 is in the 2nd position.

In other words, the positions of the digits 1 to 4 of 3412 recreate its own digits:

3412 → (3,4,1,2) → 3412

The number 3412 describes itself – it’s autonomatic (from Greek auto, “self” + onoma, “name”). So are these numbers:

1
21
132
2143
52341
215634
7243651
68573142
321654798

More precisely, they’re panautonomatic numbers, because they describe the positions of all their own digits (Greek pan or panto, “all”). But what if you use the positions of only, say, the 1s or the 3s in a number? In base ten, only one number describes itself like that: 1. But we’re not confined to base 10. In base 2, the positions of the 1s in 110 (= 6) are 1 and 10 (= 2). So 110 is monautonomatic in binary (Greek mono, “single”). 10 is also monautonomatic in binary, if the digit being described is 0: it’s in 2nd position or position 10 in binary. These numbers are monoautonomatic in binary too:

110100 = 52 (digit = 1)
10100101111 = 1327 (d=0)

In 110100, the 1s are in 1st, 2nd and 4th position, or positions 1, 10, 100 in binary. In 10100101111, the 0s are in 2nd, 4th, 5th and 7th position, or positions 10, 100, 101, 111 in binary. Here are more monautonomatic numbers in other bases:

21011 in base 4 = 581 (digit = 1)
11122122 in base 3 = 3392 (d=2)
131011 in base 5 = 5131 (d=1)
2101112 in base 4 = 9302 (d=1)
11122122102 in base 3 = 91595 (d=2)
13101112 in base 5 = 128282 (d=1)
210111221 in base 4 = 148841 (d=1)

For example, in 131011 the 1s are in 1st, 3rd, 5th and 6th position, or positions 1, 3, 10 and 11 in quinary. But these numbers run out quickly and the only monautonomatic number in bases 6 and higher is 1. However, there are infinitely long monoautonomatic integer sequences in all bases. For example, in binary this sequence at the Online Encyclopedia of Integer Sequences describes itself using the positions of its 1s:

A167502: 1, 10, 100, 111, 1000, 1001, 1010, 1110, 10001, 10010, 10100, 10110, 10111, 11000, 11010, 11110, 11111, 100010, 100100, 100110, 101001, 101011, 101100, 101110, 110000, 110001, 110010, 110011, 110100, 111000, 111001, 111011, 111101, 11111, …

In base 10, it looks like this:

A167500: 1, 2, 4, 7, 8, 9, 10, 14, 17, 18, 20, 22, 23, 24, 26, 30, 31, 34, 36, 38, 41, 43, 44, 46, 48, 49, 50, 51, 52, 56, 57, 59, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 75, 77, 80, 83, 86, 87, 89, 91, 94, 95, 97, 99, 100, 101, 103, 104, 107, 109, 110, 111, 113, 114, 119, 120, 124, … (see A287515 for a similar sequence using 0s)

T4K1NG S3LF13S

It’s like watching a seed grow. You take a number and count how many 0s it contains, then how many 1s, how many 2s, 3s, 4s and so on. Then you create a new number by writing the count of each digit followed by the digit itself. Then you repeat the process with the new number.

1

The count of digits is one 1, so the new number is this:

→ 11

The count of digits for 11 is two 1s, so the next number is:

→ 21

The count of digits for 21 is one 1, one 2, so the next number is:

→ 1112

The count of digits for 1112 is three 1s, one 2, so the next number is:

→ 3112

The count of digits for 3112 is two 1s, one 2, one 3, so the next number is:

→ 211213

What happens after that? Here are the numbers as a sequence:

1 → 11 → 21 → 1112 → 3112 → 211213 → 312213 → 212223 → 114213 → 31121314 → 41122314 → 31221324 → 21322314

That’s all you need, because something interesting happens with 21322314. The digit count is two 1s, three 2s, two 3s, one 4, so the next number is:

→ 21322314

In other words, 21322314 is what might be called a self-descriptive number: it describes the count of its own digits. That’s why I think this procedure is like watching a seed grow. You start with the tiny seed of 1 and end in the giant oak of 21322314, whose factorization is 2 * 3^2 * 13 * 91121. But there are many more self-descriptive numbers in base ten and some of them are much bigger than 21322314. A047841 at the Online Encyclopedia of Integer Sequences lists all 109 of them (and calls them “autobiographical numbers”). Here are a few, starting with the simplest possible:

22 → two 2s → 22
10213223 → one 0, two 1s, three 2s, two 3s → 10213223
10311233 → one 0, three 1s, one 2, three 3s → 10311233
21322314 → two 1s, three 2s, two 3s, one 4 → 21322314
21322315 → two 1s, three 2s, two 3s, one 5 → 21322315
21322316 → two 1s, three 2s, two 3s, one 6 → 21322316*
1031223314 → one 0, three 1s, two 2s, three 3s, one 4 → 10
31223314
3122331415 → three 1s, two 2s, three 3s, one 4, one 5
→ 3122331415
3122331416 → three 1s, two 2s, three 3s, one 4, one 6
→ 3122331416*

*And for 21322317, 21322318, 21322319; 3122331417, 3122331418, 3122331419.

And here’s what happens when you seed a sequence with a number containing all possible digits in base ten:

1234567890 → 10111213141516171819 → 101111213141516171819 → 101211213141516171819 → 101112213141516171819

That final number is self-descriptive:

101112213141516171819 → one 0, eleven 1s, two 2s, one 3, one 4, one 5, one 6, one 7, one 8, one 9 → 101112213141516171819

So some numbers are self-descriptive and some start a sequence that ends in a self-descriptive number. But that doesn’t exhaust the possibilities. Some numbers are part of a loop:

103142132415 → 104122232415 → 103142132415
104122232415 → 103142132415 → 104122232415
1051421314152619 → 1061221324251619 → 1051421314152619…
5142131415261819 → 6122132425161819 → 5142131415261819
106142131416271819 → 107122132426171819 → 106142131416271819

10512223142518 → 10414213142518 → 10512213341518 → 10512223142518
51222314251718 → 41421314251718 → 51221334151718 →
51222314251718

But all that is base ten. What about other bases? In fact, nearly all self-descriptive numbers in base ten are also self-descriptive in other bases. An infinite number of other bases, in fact. 22 is a self-descriptive number for all b > 2. The sequence seeded with 1 is identical in all b > 4:

1 → 11 → 21 → 1112 → 3112 → 211213 → 312213 → 212223 → 114213 → 31121314 → 41122314 → 31221324 → 2132231421322314

In bases 2, 3 and 4, the sequence seeded with 1 looks like this:

1 → 11 → 101 → 10101 → 100111 → 1001001 → 1000111 → 11010011101001… (b=2) (1101001[2] = 105 in base 10)
1 → 11 → 21 → 1112 → 10112 → 1010112 → 2011112 → 10111221011122… (b=3) (1011122[3] = 854 in base 10)
1 → 11 → 21 → 1112 → 3112 → 211213 → 312213 → 212223 → 1110213 → 101011213 → 201111213 → 101112213101112213… (b=4) (101112213[4] = 71079 in base 10)

In base 2 there are only two self-descriptive numbers (and no loops):

111 → three 1s → 111… (b=2) (111 = 7 in base 10)
1101001 → three 0s, four 1s → 1101001… (b=2) (1101001 = 105 in base 10)

So if you apply the “count digits” procedure in base 2, all numbers, except 111, begin a sequence that ends in 1101001. Base 3 has a few more self-descriptive numbers and also some loops:

2222… (b >= 3)
10111 → one 0, four 1s → 10111… (b=3)
11112 → four 1s, one 2 → 11112
100101 → three 0s, three 1s → 100101… (b=3)
1011122 → one 0, four 1s, two 2s → 1011122… (b=3)
2021102 → two 0s, two 1s, three 2s → 2021102… (b=3)
10010122 → three 0s, three 1s, two 2s → 10010122

2012112 → 10101102 → 10011112 → 2012112
10011112 → 2012112 → 10101102 → 10011112
10101102 → 10011112 → 2012112 → 10101102

A question I haven’t been able to answer: Is there a base in which loops can be longer than these?

103142132415 → 104122232415 → 103142132415
10512223142518 → 10414213142518 → 10512213341518 → 10512223142518

A question I have been able to answer: What is the sequence when it’s seeded with the title of this blog-post? T4K1NGS3LF13S is a number in all bases >= 30 and its base-30 form equals 15,494,492,743,722,316,018 in base 10 (with the factorization 2 * 72704927 * 106557377767). If T4K1NGS3LF13S seeds a sequence in any b >= 30, the result looks like this:

T4K1NGS3LF13S → 2123141F1G1K1L1N2S1T → 813213141F1G1K1L1N1S1T → A1122314181F1G1K1L1N1S1T → B1221314181A1F1G1K1L1N1S1T → C1221314181A1B1F1G1K1L1N1S1T → D1221314181A1B1C1F1G1K1L1N1S1T → E1221314181A1B1C1D1F1G1K1L1N1S1T → F1221314181A1B1C1D1E1F1G1K1L1N1S1T → G1221314181A1B1C1D1E2F1G1K1L1N1S1T → F1321314181A1B1C1D1E1F2G1K1L1N1S1T → F1222314181A1B1C1D1E2F1G1K1L1N1S1T → E1421314181A1B1C1D1E2F1G1K1L1N1S1T → F1221324181A1B1C1D2E1F1G1K1L1N1S1T → E1421314181A1B1C1D1E2F1G1K1L1N1S1T