Magistra Rules the Waves

One of my favourite integer sequences has the simple formula n(i) = n(i-1) + digitsum(n(i-1)). If it’s seeded with 1, its first few terms go like this:

n(1) = 1
n(2) = n(1) + digitsum(n(1)) = 1 + digitsum(1) = 2
n(3) = 2 + digitsum(2) = 4
n(4) = 4 + digitsum(4) = 8
n(5) = 8 + digitsum(8) = 16
n(6) = 16 + digitsum(16) = 16 + 1+6 = 16 + 7 = 23
n(7) = 23 + digitsum(23) = 23 + 2+3 = 23 + 5 = 28
n(8) = 28 + digitsum(28) = 28 + 2+8 = 28 + 10 = 38

As a sequence, it looks like this:

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…

Given a number at random, is there a quick way to say whether it appears in the sequence seeded with 1? Not that I know, with one exception. If the number is divisible by 3, it doesn’t appear, at least in base 10. In base 2, that rule doesn’t apply:

n(1) = 1
n(2) = 1 + digitsum(1) = 10 = 1 + 1 = 2
n(3) = 10 + digitsum(10) = 10 + 1 = 11 = 2 + 1 = 3
n(4) = 11 + digitsum(11) = 11 + 1+1 = 101 = 3 + 2 = 5
n(5) = 101 + digitsum(101) = 101 + 1+0+1 = 111 = 5 + 2 = 7
n(6) = 111 + digitsum(111) = 111 + 11 = 1010 = 7 + 3 = 10
n(7) = 1010 + digitsum(1010) = 1010 + 10 = 1100 = 10 + 2 = 12
n(8) = 1100 + digitsum(1100) = 1100 + 10 = 1110 = 12 + 2 = 14

1, 2, 3, 5, 7, 10, 12, 14, 17, 19, 22, 25, 28, 31, 36, 38, 41, 44, 47, 52, 55, 60, 64, 65, 67, 70, 73, 76, 79, 84, 87, 92, 96, 98, 101, 105, 109, 114, 118, 123, 129, 131, 134, 137, 140, 143, 148, 151, 156, 160, 162, 165, 169, 173, 178, 182, 187, 193, 196, 199, 204, 208, 211, 216, 220, 225, 229, 234, 239, 246, 252, 258, 260, 262, 265, 268, 271, 276, 279, 284, 288, 290, 293, 297, 301, 306, 310, 315, 321, 324, 327, 332, 336, 339, 344, 348, 353, 357, 362, 367, 374…

What patterns are there in these sequences? It’s easier to check when they’re represented graphically, so I converted them into patterns à la the Ulam spiral, where n is represented as a dot on a spiral of integers. This is the spiral for base 10:

ulambase10Base 10


And these are the spirals for bases 2 and 3:

ulambase2

Base 2


ulambase3

Base 3


These sequences look fairly random to me: there are no obvious patterns in the jumps from n(i) to n(i+1), i.e. in the values for digitsum(n(i)). Now try the spirals for bases 9 and 33:

ulambase9

Base 9


ulambase33

Base 33


Patterns have appeared: there is some regularity in the jumps. You can see these regularities more clearly if you represent digitsum(n(i)) as a graph, with n(i) on the x axis and digitsum(n(i)) on the y axis. If the graph starts with n(i) = 1 on the lower left and proceeds left-right, left-right up the screen, it looks like this in base 10:

base10

Base 10 (click to enlarge)


Here are bases 2 and 3:

base2

Base 2


base3

Base 3


The jumps seem fairly random. Now try bases 9, 13, 16, 17, 25, 33 and 49:

base9

Base 9


base13

Base 13


base16

Base 16


base17

Base 17


base25

Base 25


base33

Base 33


base49

Base 49


In some bases, the formula n(i) = n(i-1) + digitsum(n(i-1)) generates mild randomness. In others, it generates strong regularity, like waves rolling ashore under a steady wind. I don’t understand why, but regularity seems to occur in bases that are one more than a power of 2 and also in some bases that are primes or squares.


Elsewhere other-posted:

Mathematica Magistra Mundi
8200_idf_insignia

Advertisements

Dig Sum Fib

The Fibonacci sequence is an infinitely rich sequence based on a very simple rule: add the previous two numbers. If the first two numbers are 1 and 1, the sequence begins like this:

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…

Plainly, the numbers increase for ever. The hundredth Fibonacci number is 354,224,848,179,261,915,075, for example, and the two-hundredth is 280,571,172,992,510,140,037,611,932,413,038,677,189,525. But there are variants on the Fibonacci sequence that don’t increase for ever. The standard rule is n(i) = n(i-2) + n(i-1). What if the rule becomes n(i) = digitsum(n(i-2)) + digitsum(n(i-1))? Now the sequence falls into a loop, like this:

1, 1, 2, 3, 5, 8, 13, 12, 7, 10, 8, 9, 17, 17, 16, 15, 13, 10, 5, 6, 11, 8, 10, 9, 10, 10, 2, 3… (length=28)

But that’s in base 10. Here are the previous bases:

1, 1, 2, 2, 2… (base=2) (length=5)
1, 1, 2, 3, 3, 2, 3… (b=3) (l=7)
1, 1, 2, 3, 5, 5, 4, 3, 4, 4, 2, 3… (b=4) (l=12)
1, 1, 2, 3, 5, 4, 5, 5, 2, 3… (b=5) (l=10)
1, 1, 2, 3, 5, 8, 8, 6, 4, 5, 9, 9, 8, 7, 5, 7, 7, 4, 6, 5, 6, 6, 2, 3… (b=6) (l=24)
1, 1, 2, 3, 5, 8, 7, 3, 4, 7, 5, 6, 11, 11, 10, 9, 7, 4, 5, 9, 8, 5, 7, 6, 7, 7, 2, 3… (b=7) (l=28)
1, 1, 2, 3, 5, 8, 6, 7, 13, 13, 12, 11, 9, 6, 8, 7, 8, 8, 2, 3… (b=8) (l=20)
1, 1, 2, 3, 5, 8, 13, 13, 10, 7, 9, 8, 9, 9, 2, 3… (b=9) (l=16)

Apart from base 2, all the bases repeat with (2, 3), which is set up in each case by (base, base) = (10, 10) in that base, equivalent to (1, 1). All bases > 2 appear to repeat with (2, 3), but I don’t understand why. The length of the sequence varies widely. Here it is in bases 29, 30 and 31:

1, 1, 2, 3, 5, 8, 13, 21, 34, 27, 33, 32, 9, 13, 22, 35, 29, 8, 9, 17, 26, 43, 41, 28, 41, 41, 26, 39, 37, 20, 29, 21, 22, 43, 37, 24, 33, 29, 6, 7, 13, 20, 33, 25, 30, 27, 29, 28, 29, 29, 2, 3… (b=29) (l=52)

1, 1, 2, 3, 5, 8, 13, 21, 34, 26, 31, 28, 30, 29, 30, 30, 2, 3 (b=30) (l=18)

1, 1, 2, 3, 5, 8, 13, 21, 34, 25, 29, 54, 53, 47, 40, 27, 37, 34, 11, 15, 26, 41, 37, 18, 25, 43, 38, 21, 29, 50, 49, 39, 28, 37, 35, 12, 17, 29, 46, 45, 31, 16, 17, 33, 20, 23, 43, 36, 19, 25, 44, 39, 23, 32, 25, 27, 52, 49, 41, 30, 41, 41, 22, 33, 25, 28, 53, 51, 44, 35, 19, 24, 43, 37, 20, 27, 47, 44, 31, 15, 16, 31, 17, 18, 35, 23, 28, 51, 49, 40, 29, 39, 38, 17, 25, 42, 37, 19, 26, 45, 41, 26, 37, 33, 10, 13, 23, 36, 29, 35, 34, 9, 13, 22, 35, 27, 32, 29, 31, 30, 31, 31, 2, 3 (b=31) (l=124)

The sequence for base 77 is short like that for base 30:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 68, 81, 73, 78, 75, 77, 76, 77, 77, 2, 3 (b=77) (l=22)

But the sequence for base 51 is this:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 39, 44, 83, 77, 60, 37, 47, 84, 81, 65, 46, 61, 57, 18, 25, 43, 68, 61, 29, 40, 69, 59, 28, 37, 65, 52, 17, 19, 36, 55, 41, 46, 87, 83, 70, 53, 23, 26, 49, 75, 74, 49, 73, 72, 45, 67, 62, 29, 41, 70, 61, 31, 42, 73, 65, 38, 53, 41, 44, 85, 79, 64, 43, 57, 50, 57, 57, 14, 21, 35, 56, 41, 47, 88, 85, 73, 58, 31, 39, 70, 59, 29, 38, 67, 55, 22, 27, 49, 76, 75, 51, 26, 27, 53, 30, 33, 63, 46, 59, 55, 14, 19, 33, 52, 35, 37, 72, 59, 31, 40, 71, 61, 32, 43, 75, 68, 43, 61, 54, 15, 19, 34, 53, 37, 40, 77, 67, 44, 61, 55, 16, 21, 37, 58, 45, 53, 48, 51, 49, 50, 99, 99, 98, 97, 95, 92, 87, 79, 66, 45, 61, 56, 17, 23, 40, 63, 53, 16, 19, 35, 54, 39, 43, 82, 75, 57, 32, 39, 71, 60, 31, 41, 72, 63, 35, 48, 83, 81, 64, 45, 59, 54, 13, 17, 30, 47, 77, 74, 51, 25, 26, 51, 27, 28, 55, 33, 38, 71, 59, 30, 39, 69, 58, 27, 35, 62, 47, 59, 56, 15, 21, 36, 57, 43, 50, 93, 93, 86, 79, 65, 44, 59, 53, 12, 15, 27, 42, 69, 61, 30, 41, 71, 62, 33, 45, 78, 73, 51, 24, 25, 49, 74, 73, 47, 70, 67, 37, 54, 41, 45, 86, 81, 67, 48, 65, 63, 28, 41, 69, 60, 29, 39, 68, 57, 25, 32, 57, 39, 46, 85, 81, 66, 47, 63, 60, 23, 33, 56, 39, 45, 84, 79, 63, 42, 55, 47, 52, 49, 51, 50, 51, 51, 2, 3… (b=51) (l=304)

The Rite of Sling

Duels are interesting things. Flashman made his name in one and earnt an impressive scar in another. Maupassant explored their psychology and so did his imitator Maugham. Game theory might be a good guide on how to fight one, but I’d like to look at something simpler: the concept of duelling numbers.

How would two numbers fight? One way is to use digit-sums. Find the digit-sum of each number, then take it away from the other number. Repeat until one or both numbers <= 0, like this:

function duel(n1,n2){
print(n1," <-> ",n2);
do{
s1=digitsum(n1);
s2=digitsum(n2);
n1 -= s2;
n2 -= s1;
print(” -> ",n1," <-> ",n2);
}while(n1>0 && n2>0);
}

Suppose n1 = 23 and n2 = 22. At the first step, s1 = digitsum(23) = 5 and s2 = digitsum(22) = 4. So n1 = 23 – 4 = 19 and n2 = 22 – 5 = 17. And what happens in the end?

23 ↔ 22 ➔ 19 ↔ 17 ➔ 11 ↔ 7 ➔ 4 ↔ 5 ➔ -1 ↔ 1

So 23 loses the duel with 22. Now try 23 vs 24:

23 ↔ 24 ➔ 17 ↔ 19 ➔ 7 ↔ 11 ➔ 5 ↔ 4 ➔ 1 ↔ -1

23 wins the duel with 24. The gap can be bigger. For example, 85 and 100 are what might be called David and Goliath numbers, because the David of 85 beats the Goliath of 100:

85 ↔ 100 ➔ 84 ↔ 87 ➔ 69 ↔ 75 ➔ 57 ↔ 60 ➔ 51 ↔ 48 ➔ 39 ↔ 42 ➔ 33 ↔ 30 ➔ 30 ↔ 24 ➔ 24 ↔ 21 ➔ 21 ↔ 15 ➔ 15 ↔ 12 ➔ 12 ↔ 6 ➔ 6 ↔ 3 ➔ 3 ↔ -3

999 and 1130 are also David and Goliath numbers:

999 ↔ 1130 ➔ 994 ↔ 1103 ➔ 989 ↔ 1081 ➔ 979 ↔ 1055 ➔ 968 ↔ 1030 ➔ 964 ↔ 1007 ➔ 956 ↔ 988 ➔ 931 ↔ 968 ➔ 908 ↔ 955 ➔ 889 ↔ 938 ➔ 869 ↔ 913 ➔ 856 ↔ 890 ➔ 839 ↔ 871 ➔ 823 ↔ 851 ➔ 809 ↔ 838 ➔ 790 ↔ 821 ➔ 779 ↔ 805 ➔ 766 ↔ 782 ➔ 749 ↔ 763 ➔ 733 ↔ 743 ➔ 719 ↔ 730 ➔ 709 ↔ 713 ➔ 698 ↔ 697 ➔ 676 ↔ 674 ➔ 659 ↔ 655 ➔ 643 ↔ 635 ➔ 629 ↔ 622 ➔ 619 ↔ 605 ➔ 608 ↔ 589 ➔ 586 ↔ 575 ➔ 569 ↔ 556 ➔ 553 ↔ 536 ➔ 539 ↔ 523 ➔ 529 ↔ 506 ➔ 518 ↔ 490 ➔ 505 ↔ 476 ➔ 488 ↔ 466 ➔ 472 ↔ 446 ➔ 458 ↔ 433 ➔ 448 ↔ 416 ➔ 437 ↔ 400 ➔ 433 ↔ 386 ➔ 416 ↔ 376 ➔ 400 ↔ 365 ➔ 386 ↔ 361 ➔ 376 ↔ 344 ➔ 365 ↔ 328 ➔ 352 ↔ 314 ➔ 344 ↔ 304 ➔ 337 ↔ 293 ➔ 323 ↔ 280 ➔ 313 ↔ 272 ➔ 302 ↔ 265 ➔ 289 ↔ 260 ➔ 281 ↔ 241 ➔ 274 ↔ 230 ➔ 269 ↔ 217 ➔ 259 ↔ 200 ➔ 257 ↔ 184 ➔ 244 ↔ 170 ➔ 236 ↔ 160 ➔ 229 ↔ 149 ➔ 215 ↔ 136 ➔ 205 ↔ 128 ➔ 194 ↔ 121 ➔ 190 ↔ 107 ➔ 182 ↔ 97 ➔ 166 ↔ 86 ➔ 152 ↔ 73 ➔ 142 ↔ 65 ➔ 131 ↔ 58 ➔ 118 ↔ 53 ➔ 110 ↔ 43 ➔ 103 ↔ 41 ➔ 98 ↔ 37 ➔ 88 ↔ 20 ➔ 86 ↔ 4 ➔ 82 ↔ -10

You can look in the other direction and find bully numbers, or numbers that beat all numbers smaller than themselves. In base 10, the numbers 2 to 9 obviously do. So do these:

35, 36, 37, 38, 39, 47, 48, 49, 58, 59, 64, 65, 66, 67, 68, 69, 76, 77, 78, 79, 189

In other bases, bullies are sometimes common, sometimes rare. Sometimes they don’t exist at all for n > b. Here are bully numbers for bases 2 to 30:

base=2: 3, 5, 7, 13, 15, 21, 27, 29, 31, 37, 43, 45, 47, 54, 59
b=3: 4, 5, 7, 8, 14
b=4: 5, 6, 7, 9, 10, 11, 14, 15, 27, 63
b=5: 12, 13, 14, 18, 19, 23, 24
b=6: 15, 16, 17, 22, 23, 26, 27, 28, 29, 32, 33, 34, 35, 65, 71, 101
b=7: 17, 18, 19, 20, 24, 25, 26, 27, 32, 33, 34, 40, 41, 45, 46, 47, 48, 76
b=8: 37, 38, 39, 46, 47, 59, 60, 61, 62, 63, 95, 103, 111, 119
b=9: 42, 43, 44, 52, 53, 61, 62
b=10: 35, 36, 37, 38, 39, 47, 48, 49, 58, 59, 64, 65, 66, 67, 68, 69, 76, 77, 78, 79, 189
b=11: 38, 39, 40, 41, 42, 43, 49, 50, 51, 52, 53, 54, 62, 63, 64, 65, 73, 74, 75, 76, 85, 86, 87
b=12: 57, 58, 59
b=13: 58, 59, 60, 61, 62, 63, 64, 74, 75, 76, 77, 87, 88, 89, 90, 101, 102, 103, 115, 116, 127, 128, 129
b=14: none (except 2 to 13)
b=15: 116, 117, 118, 119, 130, 131, 132, 133, 134, 147, 148, 149
b=16: 122, 123, 124, 125, 126, 127, 140, 141, 142, 143, 156, 157, 158, 159, 173, 174, 175, 190, 191, 222, 223
b=17: 151, 152, 168, 169, 185, 186
b=18: 85, 86, 87, 88, 89, 191, 192, 193, 194, 195, 196, 197, 212, 213, 214, 215
b=19: 242, 243, 244, 245, 246
b=20: none
b=21: 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 162, 163, 164, 165, 166, 167, 183, 184, 185, 186, 187, 188, 206, 207, 208, 209, 227, 228, 229, 230, 248, 249, 250, 251, 270, 271, 272
b=22: 477, 478, 479, 480, 481, 482, 483
b=23: none
b=24: none
b=25: 271, 272, 273, 274, 296, 297, 298, 299, 322, 323, 324, 348, 349, 372, 373, 374
b=26: none
b=27: none
b=28: none
b=29: 431, 432, 433, 434, 459, 460, 461, 462, 463, 490, 491, 492, 546, 547, 548, 549, 550
b=30: none

Summus

I’m interested in digit-sums and in palindromic numbers. Looking at one, I found the other. It started like this: 9^2 = 81 and 9 = 8 + 1, so digitsum(9^1) = digitsum(9^2). I wondered how long such a sequence of powers could be (excluding powers of 10). I quickly found that the digit-sum of 468 is equal to the digit-sum of its square and cube:

digsum(468) = digsum(219024) = digsum(102503232)

But I couldn’t find any longer sequence, although plenty of other numbers are similar to 468:

digsum(585) = digsum(342225) = digsum(200201625)
digsum(4680) = digsum(21902400) = digsum(102503232000)
digsum(5850) = digsum(34222500) = digsum(200201625000)
digsum(5851) = digsum(34234201) = digsum(200304310051)
digsum(5868) = digsum(34433424) = digsum(202055332032)
digsum(28845) = digsum(832034025) = digsum(24000021451125) […]
digsum(589680) = digsum(347722502400) = digsum(205045005215232000)

What about other bases? First came this sequence:

digsum(2) = digsum(11) (base = 3) (highest power = 2)

Then these:

digsum(4) = digsum(22) = digsum(121) (b=7) (highest power = 3)
digsum(8) = digsum(44) = digsum(242) = digsum(1331) (b=15) (hp=4)
digsum([16]) = digsum(88) = digsum(484) = digsum(2662) = digsum(14641) (b=31) (hp=5)

The pattern continues (a number between square brackets represents a single digit in the base):

digsum([32]) = digsum([16][16]) = digsum(8[16]8) = digsum(4[12][12]4) = digsum(28[12]82) = digsum(15[10][10]51) (b=63) (hp=6)
digsum([64]) = digsum([32][32]) = digsum([16][32][16]) = digsum(8[24][24]8) = digsum(4[16][24][16]4) = digsum(2[10][20][20][10]2) = digsum(16[15][20][15]61) (b=127) (hp=7)
digsum([128]) = digsum([64][64]) = digsum([32][64][32]) = digsum([16][48][48][16]) = digsum(8[32][48][32]8) = digsum(4[20][40][40][20]4) = digsum(2[12][30][40][30][12]2) = digsum(17[21][35][35][21]71) (b=255) (hp=8)
digsum([256]) = digsum([128][128]) = digsum([64][128][64]) = digsum([32][96][96][32]) = digsum([16][64][96][64][16]) = digsum(8[40][80][80][40]8) = digsum(4[24][60][80][60][24]4) = digsum(2[14][42][70][70][42][14]2) = digsum(18[28][56][70][56][28]81) (b=511) (hp=9)

After this, I looked at sequences in which n(i) = n(i-1) + digitsum(n(i-1)). How long could digitsum(n(i)) be greater than or equal to digitsum(n(i-1))? In base 10, I found these sequences:

1 (digitsum=1) → 2 → 4 → 8 → 16 (sum=7) (count=4) (base=10)
9 → 18 (sum=9) → 27 (s=9) → 36 (s=9) → 45 (s=9) → 54 (s=9) → 63 (s=9) → 72 (s=9) → 81 (s=9) → 90 (s=9) → 99 (s=18) → 117 (s=9) (c=11) (b=10)
801 (s=9) → 810 (s=9) → 819 (s=18) → 837 (s=18) → 855 (s=18) → 873 (s=18) → 891 (s=18) → 909 (s=18) → 927 (s=18) → 945 (s=18) → 963 (s=18) → 981 (s=18) → 999 (s=27) → 1026 (s=9) (c=13)

Base 2 does better:

1 → 10 (s=1) → 11 (s=2) → 101 (s=2) → 111 (s=3) → 1010 (s=2) (c=5) (b=2)
16 = 10000 (s=1) → 10001 (s=2) → 10011 (s=3) → 10110 (s=3) → 11001 (s=3) → 11100 (s=3) → 11111 (s=5) → 100100 (s=2) (c=7) (b=2)
962 = 1111000010 (s=5) → 1111000111 (s=7) → 1111001110 (s=7) → 1111010101 (s=7) → 1111011100 (s=7) → 1111100011 (s=7) → 1111101010 (s=7) → 1111110001 (s=7) → 1111111000 (s=7) → 1111111111 (s=10) → 10000001001 (s=3) (c=10) (b=2)
524047 = 1111111111100001111 (s=15) → 1111111111100011110 (s=15) → 1111111111100101101 (s=15) → 1111111111100111100 (s=15) → 1111111111101001011 (s=15) → 1111111111101011010 (s=15) → 1111111111101101001(s=15) → 1111111111101111000 (s=15) → 1111111111110000111 (s=15) → 1111111111110010110 (s=15) → 1111111111110100101 (s=15) → 1111111111110110100 (s=15) → 1111111111111000011 (s=15) → 1111111111111010010 (s=15) → 1111111111111100001 (s=15) → 1111111111111110000 (s=15) → 1111111111111111111 (s=19) → 10000000000000010010 (s=3) (c=17) (b=2)

The best sequence I found in base 3 is shorter than in base 10, but there are more sequences:

1 → 2 → 11 (s=2) → 20 (s=2) → 22 (s=4) → 110 (s=2) (c=5) (b=3)
31 = 1011 (s=3) → 1021 (s=4) → 1102 (s=4) → 1120 (s=4) → 1201 (s=4) → 1212 (s=6) → 2002 (s=4) (c=6) (b=3)
54 = 2000 (s=2) → 2002 (s=4) → 2020 (s=4) → 2101 (s=4) → 2112 (s=6) → 2202 (s=6) → 2222 (s=8) → 10021(s=4) (c=7) (b=3)
432 = 121000 (s=4) → 121011 (s=6) → 121101 (s=6) → 121121 (s=8) → 121220 (s=8) → 122012 (s=8) → 122111 (s=8) → 122210 (s=8) → 200002 (s=4) (c=8) (b=3)
648 = 220000 (s=4) → 220011 (s=6) → 220101 (s=6) → 220121 (s=8) → 220220 (s=8) → 221012 (s=8) → 221111 (s=8) → 221210 (s=8) → 222002 (s=8) → 222101 (s=8) → 222200 (s=8) → 222222 (s=12) → 1000102 (s=4) (c=12) (b=3)

And what about sequences in which digitsum(n(i)) is always greater than digitsum(n(i-1))? Base 10 is disappointing:

1 → 2 → 4 → 8 → 16 (sum=7) (count=4) (base=10)
50 (s=5) → 55 (s=10) → 65 (s=11) → 76 (s=13) → 89 (s=17) → 106 (s=7) (c=5) (b=10)

Some other bases do better:

2 = 10 (s=1) → 11 (s=2) → 101 (s=2) (c=2) (b=2)
4 = 100 (s=1) → 101 (s=2) → 111 (s=3) → 1010 (s=2) (c=3) (b=2)
240 = 11110000 (s=4) → 11110100 (s=5) → 11111001 (s=6) → 11111111 (s=8) → 100000111 (s=4) (c=4) (b=2)

1 → 2 → 11 (s=2) (c=2) (b=3)
19 = 201 (s=3) → 211 (s=4) → 222 (s=6) → 1012 (s=4) (c=3) (b=3)
58999 = 2222221011 (s=15) → 2222221201 (s=16) → 2222222022 (s=18) → 2222222222 (s=20) → 10000000201 (s=4) (c=4) (b=3)

1 → 2 → 10 (s=1) (c=2) (b=4)
4 = 10 (s=1) → 11 (s=2) → 13 (s=4) → 23 (s=5) → 100 (s=1) (c=4) (b=4)
977 = 33101 (s=8) → 33121 (s=10) → 33203 (s=11) → 33232 (s=13) → 33323 (s=14) → 100021 (s=4) (c=5) (b=4)

1 → 2 → 4 → 13 (s=4) (c=3) (b=5)
105 = 410 (s=5) → 420 (s=6) → 431 (s=8) → 444 (s=12) → 1021 (s=4) (c=4) (b=5)

1 → 2 → 4 → 12 (s=3) (c=3) (b=6)
13 = 21 (s=3) → 24 (s=6) → 34 (s=7) → 45 (s=9) → 102 (s=3) (c=4) (b=6)
396 = 1500 (s=6) → 1510 (s=7) → 1521 (s=9) → 1534 (s=13) → 1555 (s=16) → 2023 (s=7) (c=5) (b=6)

1 → 2 → 4 → 11 (s=2) (c=3) (b=7)
121 = 232 (s=7) → 242 (s=8) → 253 (s=10) → 266 (s=14) → 316 (s=10) (c=4) (b=7)
205 = 412 (s=7) → 422 (s=8) → 433 (s=10) → 446 (s=14) → 466 (s=16) → 521 (s=8) (c=5) (b=7)

1 → 2 → 4 → 10 (s=1) (c=3) (b=8)
8 = 10 (s=1) → 11 (s=2) → 13 (s=4) → 17 (s=8) → 27 (s=9) → 40 (s=4) (c=5) (b=8)
323 = 503 (s=8) → 513 (s=9) → 524 (s=11) → 537 (s=15) → 556 (s=16) → 576 (s=18) → 620 (s=8) (c=6) (b=8)

1 → 2 → 4 → 8 → 17 (s=8) (c=4) (b=9)
6481 = 8801 (s=17) → 8820 (s=18) → 8840 (s=20) → 8862 (s=24) → 8888 (s=32) → 10034 (s=8) (c=5) (b=9)

1 → 2 → 4 → 8 → 16 (s=7) (c=4) (b=10)
50 (s=5) → 55 (s=10) → 65 (s=11) → 76 (s=13) → 89 (s=17) → 106 (s=7) (c=5) (b=10)

1 → 2 → 4 → 8 → 15 (s=6) (c=4) (b=11)
1013 = 841 (s=13) → 853 (s=16) → 868 (s=22) → 888 (s=24) → 8[10][10] (s=28) → 925 (s=16) (c=5) (b=11)

1 → 2 → 4 → 8 → 14 (s=5) (c=4) (b=12)
25 = 21 (s=3) → 24 (s=6) → 2[10] (s=12) → 3[10] (s=13) → 4[11] (s=15) → 62 (s=8) (c=5) (b=12)
1191 = 833 (s=14) → 845 (s=17) → 85[10] (s=23) → 879 (s=24) → 899 (s=26) → 8[11][11] (s=30) → 925 (s=16) (c=6) (b=12)

1 → 2 → 4 → 8 → 13 (s=4) (c=4) (b=13)
781 = 481 (s=13) → 491 (s=14) → 4[10]2 (s=16) → 4[11]5 (s=20) → 4[12][12] (s=28) → 521 (s=8) (c=5) (b=13)
19621 = 8[12]14 (s=25) → 8[12]33 (s=26) → 8[12]53 (s=28) → 8[12]75 (s=32) → 8[12]9[11] (s=40) → 8[12][12][12] (s=44) → 9034 (s=16) (c=6) (b=13)

1 → 2 → 4 → 8 → 12 (s=3) (c=4) (b=14)
72 = 52 (s=7) → 59 (s=14) → 69 (s=15) → 7[10] (s=17) → 8[13] (s=21) → [10]6 (s=16) (c=5) (b=14)
1275 = 671 (s=14) → 681 (s=15) → 692 (s=17) → 6[10]5 (s=21) → 6[11][12] (s=29) → 6[13][13] (s=32) → 723 (s=12) (c=6) (b=14)
19026 = 6[13]10 (s=20) → 6[13]26 (s=27) → 6[13]45 (s=28) → 6[13]65 (s=30) → 6[13]87 (s=34) → 6[13][10][13] (s=42) → 6[13][13][13] (s=45) → 7032 (s=12) (c=7) (b=14)

1 → 2 → 4 → 8 → 11 (s=2) (c=4) (b=15)
603 = 2[10]3 (s=15) → 2[11]3 (s=16) → 2[12]4 (s=18) → 2[13]7 (s=22) → 2[14][14] (s=30) → 31[14] (s=18) (c=5) (b=15)
1023 = 483 (s=15) → 493 (s=16) → 4[10]4 (s=18) → 4[11]7 (s=22) → 4[12][14] (s=30) → 4[14][14] (s=32) → 521 (s=8) (c=6) (b=15)
1891 = 861 (s=15) → 871 (s=16) → 882 (s=18) → 895 (s=22) → 8[10][12] (s=30) → 8[12][12] (s=32) → 8[14][14] (s=36) → 925 (s=16) (c=7) (b=15)

1 → 2 → 4 → 8 → 10 (s=1) (c=4) (b=16)
16 = 10 (s=1) → 11 (s=2) → 13 (s=4) → 17 (s=8) → 1[15] (s=16) → 2[15] (s=17) → 40 (s=4) (c=6) (b=16)
1396 = 574 (s=16) → 584 (s=17) → 595 (s=19) → 5[10]8 (s=23) → 5[11][15] (s=31) → 5[13][14] (s=32) → 5[15][14] (s=34) → 620 (s=8) (c=7) (b=16)
2131 = 853 (s=16) → 863 (s=17) → 874 (s=19) → 887 (s=23) → 89[14] (s=31) → 8[11][13] (s=32) → 8[13][13] (s=34) → 8[15][15] (s=38) → 925 (s=16) (c=8) (b=16)

1 → 2 → 4 → 8 → [16] (s=16) → 1[15] (s=16) (c=5) (b=17)

1 → 2 → 4 → 8 → [16] (s=16) → 1[14] (s=15) (c=5) (b=18)
5330 = [16]82 (s=26) → [16]9[10] (s=35) → [16][11]9 (s=36) → [16][13]9 (s=38) → [16][15][11] (s=42) → [16][17][17] (s=50) → [17]2[13] (s=32) (c=6) (b=18)

1 → 2 → 4 → 8 → [16] (s=16) → 1[13] (s=14) (c=5) (b=19)
116339 = [16][18]52 (s=41) → [16][18]75 (s=46) → [16][18]9[13] (s=56) → [16][18][12][12] (s=58) → [16][18][15][13] (s=62) → [16][18][18][18] (s=70) → [17]03[12] (s=32) (c=6) (b=19)

1 → 2 → 4 → 8 → [16] (s=16) → 1[12] (s=13) (c=5) (b=20)
100 = 50 (s=5) → 55 (s=10) → 5[15] (s=20) → 6[15] (s=21) → 7[16] (s=23) → 8[19] (s=27) → [10]6 (s=16) (c=6) (b=20)
135665 = [16][19]35 (s=43) → [16][19]58 (s=48) → [16][19]7[16] (s=58) → [16][19][10][14] (s=59) → [16][19][13][13] (s=61) → [16][19][16][14] (s=65) → [16][19][19][19] (s=73) → [17]03[12] (s=32) (c=7) (b=20)

N-route

In maths, one thing leads to another. I wondered whether, in a spiral of integers, any number was equal to the digit-sum of the numbers on the route traced by moving to the origin first horizontally, then vertically. To illustrate the procedure, here is a 9×9 integer spiral containing 81 numbers:

| 65 | 64 | 63 | 62 | 61 | 60 | 59 | 58 | 57 |
| 66 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 56 |
| 67 | 38 | 17 | 16 | 15 | 14 | 13 | 30 | 55 |
| 68 | 39 | 18 | 05 | 04 | 03 | 12 | 29 | 54 |
| 69 | 40 | 19 | 06 | 01 | 02 | 11 | 28 | 53 |
| 70 | 41 | 20 | 07 | 08 | 09 | 10 | 27 | 52 |
| 71 | 42 | 21 | 22 | 23 | 24 | 25 | 26 | 51 |
| 72 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
| 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 |

Take the number 21, which is three places across and up from the bottom left corner of the spiral. The route to the origin contains the numbers 21, 22, 23, 8 and 1, because first you move right two places, then up two places. And 21 is what I call a route number, because 21 = 3 + 4 + 5 + 8 + 1 = digitsum(21) + digitsum(22) + digitsum(23) + digitsum(8) + digitsum(1). Beside the trivial case of 1, there are two more route numbers in the spiral:

58 = 13 + 14 + 6 + 7 + 7 + 6 + 4 + 1 = digitsum(58) + digitsum(59) + digitsum(60) + digitsum(61) + digitsum(34) + digitsum(15) + digitsum(4) + digitsum(1).

74 = 11 + 12 + 13 + 14 + 10 + 5 + 8 + 1 = digitsum(74) + digitsum(75) + digitsum(76) + digitsum(77) + digitsum(46) + digitsum(23) + digitsum(8) + digitsum(1).

Then I wondered about other possible routes to the origin. Think of the origin as one corner of a rectangle and the number being tested as the diagonal corner. Suppose that you always move away from the starting corner, that is, you always move up or right (or up and left, and so on, depending on where the corners lie). In a x by y rectangle, how many routes are there between the diagonal corners under those conditions?

It’s an interesting question, but first I’ve looked at the simpler case of an n by n square. You can encode each route as a binary number, with 0 representing a vertical move and 1 representing a horizontal move. The problem then becomes equivalent to finding the number of distinct ways you can arrange equal numbers of 1s and 0s. If you use this method, you’ll discover that there are two routes across the 2×2 square, corresponding to the binary numbers 01 and 10:

2x2

Across the 3×3 square, there are six routes, corresponding to the binary numbers 0011, 0101, 0110, 1001, 1010 and 1100:

3x3

Across the 4×4 square, there are twenty routes:
4x4

(Please open in new window if it fails to animate)

(Please open in new window if it fails to animate)

Across the 5×5 square, there are 70 routes:

5x5

(Please open in new window etc)

(Please open in new window etc)

Across the 6×6 and 7×7 squares, there are 252 and 924 routes:

6x6

7x7

After that, the routes quickly increase in number. This is the list for n = 1 to 14:

1, 2, 6, 20, 70, 252, 924, 3432, 12870, 48620, 184756, 705432, 2704156, 10400600… (see A000984 at the Online Encyclopedia of Integer Sequences)

After that you can vary the conditions. What if you can move not just vertically and horizontally, but diagonally, i.e. vertically and horizontally at the same time? Now you can encode the route with a ternary number, or number in base 3, with 0 representing a vertical move, 1 a horizontal move and 2 a diagonal move. As before, there is one route across a 1×1 square, but there are three across a 2×2, corresponding to the ternary numbers 01, 2 and 10:

3x3t

There are 13 routes across a 3×3 square, corresponding to the ternary numbers 0011, 201, 021, 22, 0101, 210, 1001, 120, 012, 102, 0110, 1010, 1100:

4x4t

And what about cubes, hypercubes and higher?

Prime Climb Time

The third prime is equal to the sum of the first and second primes: 2 + 3 = 5. After that, for obvious reasons, the prime-sum climbs much more rapidly than the primes themselves:

2, 3, 05, 07, 11, 13, 17, 19, 023, 029...
2, 5, 10, 17, 28, 41, 58, 77, 100, 129...

But what if you use digit-sum(p1..pn), i.e., the sum of the digits of the primes from the first to the nth? For example, the digit-sum(p1..p5) = 2 + 3 + 5 + 7 + 1+1 = 19, whereas the sum(p1..p5) = 2 + 3 + 5 + 7 + 11 = 28. Using the digit-sums of the primes, the comparison now looks like this:

2, 3, 05, 07, 11, 13, 17, 19, 23, 29...
2, 5, 10, 17, 19, 23, 31, 41, 46, 57...

The sum climbs more slowly, but still too fast. So what about a different base? In base-2, the digit-sum(p1..p3) = (1+0) + (1+1) + (1+0+1) = 1 + 2 + 2 = 5. The comparison looks like this:

2, 3, 05, 07, 11, 13, 17, 19, 23, 29...
1, 3, 05, 08, 11, 14, 16, 19, 23, 27...

For primes 3, 5, 11, 19, and 23, p = digit-sum(primes <= p) in base-2. But the cumulative digit-sum soon begins to climb too slowly:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271...

1, 3, 5, 8, 11, 14, 16, 19, 23, 27, 32, 35, 38, 42, 47, 51, 56, 61, 64, 68, 71, 76, 80, 84, 87, 091, 096, 101, 106, 110, 117, 120, 123, 127, 131, 136, 141, 145, 150, 155, 160, 165, 172, 175, 179, 184, 189, 196, 201, 206, 211, 218, 223, 230, 232, 236, 240, 245...

So what about base-3?

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59...
2, 3, 6, 9, 12, 15, 20, 23, 28, 31, 34, 37, 42, 47, 52, 59, 64...

In base-3, for p = 2, 3 and 37, p = digit-sum(primes <= p), while for p = 23, 31, 47 and 59, p = digit-sum(primes < p), like this:

2 = 2.
3 = 2 + (1+0).
37 = 2 + (1+0) + (1+2) + (2+1) + (1+0+2) + (1+1+1) + (1+2+2) + (2+0+1) + (2+1+2) + (1+0+0+2) + (1+0+1+1) + (1+1+0+1) = 2 + 1 + 3 + 3 + 3 + 3 + 5 + 3 + 5 + 3 + 3 + 3.

23 = 2 + (1+0) + (1+2) + (2+1) + (1+0+2) + (1+1+1) + (1+2+2) + (2+0+1) = 2 + 1 + 3 + 3 + 3 + 3 + 5 + 3.
31 = 2 + (1+0) + (1+2) + (2+1) + (1+0+2) + (1+1+1) + (1+2+2) + (2+0+1) + (2+1+2) + (1+0+0+2) = 2 + 1 + 3 + 3 + 3 + 3 + 5 + 3 + 5 + 3.
47 = 2 + (1+0) + (1+2) + (2+1) + (1+0+2) + (1+1+1) + (1+2+2) + (2+0+1) + (2+1+2) + (1+0+0+2) + (1+0+1+1) + (1+1+0+1) + (1+1+1+2) + (1+1+2+1) = 2 + 1 + 3 + 3 + 3 + 3 + 5 + 3 + 5 + 3 + 3 + 3 + 5 + 5.
59 = 2 + (1+0) + (1+2) + (2+1) + (1+0+2) + (1+1+1) + (1+2+2) + (2+0+1) + (2+1+2) + (1+0+0+2) + (1+0+1+1) + (1+1+0+1) + (1+1+1+2) + (1+1+2+1) + (1+2+0+2) + (1+2+2+2) = 2 + 1 + 3 + 3 + 3 + 3 + 5 + 3 + 5 + 3 + 3 + 3 + 5 + 5 + 5 + 7.

This carries on for a long time. For these primes, p = digit-sum(primes < p):

23, 31, 47, 59, 695689, 698471, 883517, 992609, 992737, 993037, 1314239, 1324361, 1324571, 1326511, 1327289, 1766291, 3174029

And for these primes, p = digit-sum(primes <= p):

3, 37, 695663, 695881, 1308731, 1308757, 1313153, 1314301, 1326097, 1766227, 3204779, 14328191

Now try the cumulative digit-sum in base-4:

2, 3, 5, 07, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59...
2, 5, 7, 11, 16, 20, 22, 26, 31, 36, 43, 47, 52, 59, 67, 72, 80... 

The sum of digits climbs too fast. Base-3 is the Goldilocks base, climbing neither too slowly, like base-2, nor too fast, like all bases greater than 3.

Reverssum

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

1, 2, 4, 8, 16, 68, 100, ?

The rule I’m using is this: Reverse the number, then add the sum of the digits. So 1 doubles till it becomes 16. Then 16 becomes 61 + 6 + 1 = 68. Then 68 becomes 86 + 8 + 6 = 100. Then 100 becomes 001 + 1 = 2. And the sequence falls into a loop.

Reversing the number means that small numbers can get big and big numbers can get small, but the second tendency is stronger for the first few seeds:

• 1 → 2 → 4 → 8 → 16 → 68 → 100 → 2
• 2 → 4 → 8 → 16 → 68 → 100 → 2
• 3 → 6 → 12 → 24 → 48 → 96 → 84 → 60 → 12
• 4 → 8 → 16 → 68 → 100 → 2 → 4
• 5 → 10 → 2 → 4 → 8 → 16 → 68 → 100 → 2
• 6 → 12 → 24 → 48 → 96 → 84 → 60 → 12
• 7 → 14 → 46 → 74 → 58 → 98 → 106 → 608 → 820 → 38 → 94 → 62 → 34 → 50 → 10 → 2 → 4 → 8 → 16 → 68 → 100 → 2
• 8 → 16 → 68 → 100 → 2 → 4 → 8
• 9 → 18 → 90 → 18
• 10 → 2 → 4 → 8 → 16 → 68 → 100 → 2

An 11-seed is a little more interesting:

11 → 13 → 35 → 61 → 23 → 37 → 83 → 49 → 107 → 709 → 923 → 343 → 353 → 364 → 476 → 691 → 212 → 217 → 722 → 238 → 845 → 565 → 581 → 199 → 1010 → 103 → 305 → 511 → 122 → 226 → 632 → 247 → 755 → 574 → 491 → 208 → 812 → 229 → 935 → 556 → 671 → 190 → 101 → 103 (11 leads to an 18-loop from 103 at step 26; total steps = 44)

Now try some higher bases:

• 1 → 2 → 4 → 8 → 15 → 57 → 86 → 80 → 15 (base=11)
• 1 → 2 → 4 → 8 → 14 → 46 → 72 → 34 → 4A → B6 → 84 → 58 → 96 → 80 → 14 (base=12)
• 1 → 2 → 4 → 8 → 13 → 35 → 5B → C8 → A6 → 80 → 13 (base=13)
• 1 → 2 → 4 → 8 → 12 → 24 → 48 → 92 → 36 → 6C → DA → C8 → A4 → 5A → B6 → 80 → 12 (base=14)
• 1 → 2 → 4 → 8 → 11 → 13 → 35 → 5B → C6 → 80 → 11 (base=15)
• 1 → 2 → 4 → 8 → 10 → 2 (base=16)

Does the 1-seed always create a short sequence? No, it gets pretty long in base-19 and base-20:

• 1 → 2 → 4 → 8 → [16] → 1D → DF → [17]3 → 4[18] → 107 → 709 → 914 → 424 → 42E → E35 → 54[17] → [17]5C → C7D → D96 → 6B3 → 3C7 → 7D6 → 6EE → E[16]2 → 2[18]8 → 90B → B1A → A2E → E3[17] → [17]5A → A7B → B90 → AC→ DD → F1 → 2C → C[16] → [18]2 → 40 → 8 (base=19)
• 1 → 2 → 4 → 8 → [16] → 1C → CE → F[18] → 108 → 80A → A16 → 627 → 731 → 13[18] → [18]43 → 363 → 36F → F77 → 794 → 4A7 → 7B5 → 5CA → ADC → CF5 → 5[17]4 → 4[18]B → B[19][17] → [18]1[18] → [18]3F → F5E → E79 → 994 → 4AB → BB9 → 9D2 → 2ED → DFB → B[17]C → C[19]B → C1E → E2[19] → [19]49 → 96B → B7F → F94 → 4B3 → 3C2 → 2D0 → D[17] → [19]3 → 51 → 1B → BD → EF → [17]3 → 4[17] → [18]5 → 71 → 1F → F[17] → [19]7 → 95 → 63 → 3F → [16]1 → 2D → D[17] (base=20)

Then it settles down again:

• 1 → 2 → 4 → 8 → [16] → 1B → BD → EE → [16]0 → 1B (base=21)
• 1 → 2 → 4 → 8 → [16] → 1A → AC → DA → BE → FE → [16]0 → 1A (base=22)
• 1 → 2 → 4 → 8 → [16] → 19 → 9B → C6 → 77 → 7[21] → [22]C → EA → BF → [16]E → [16]0 → 19 (base=23)

Base-33 is also short:

1 → 2 → 4 → 8 → [16] → [32] → 1[31] → [32]0 → 1[31] (base=33)

And so is base-35:

1 → 2 → 4 → 8 → [16] → [32] → 1[29] → [29][31] → [33][19] → [21]F → [16][22] → [23][19] → [20][30] → [32]0 → 1[29] (base=35)

So what about base-34?

1 → 2 → 4 → 8 → [16] → [32] → 1[30] → [30][32] → 10[24] → [24]0[26] → [26]26 → 63[26] → [26]47 → 75[29] → [29]6E → E8A → A9C → CA7 → 7B7 → 7B[32] → [32]C[23] → [23]E[31] → [31][16][23] → [23][18][33] → [33][20][29] → [29][23]D → D[25][26] → [26][27]9 → 9[29][20] → [20][30][33] → [33][33]1 → 21[32] → [32]23 → 341 → 14B → B4[17] → [17]59 → 96E → E74 → 485 → 58[21] → [21]95 → 5A[22] → [22]B8 → 8C[29] → [29]D[23] → [23]F[26] → [26][17][19] → [19][19][20] → [20][21]9 → 9[23]2 → 2[24]9 → 9[25]3 → 3[26]C → C[27]A → A[28][27] → [27][30]7 → 7[32][23] → [24]01 → 11F → F1[18] → [18]2F → F3[19] → [19]4[18] → [18]5[26] → [26]6[33] → [33]8[23] → [23]A[29] → [29]C[17] → [17]E[19] → [19]F[33] → [33][17][18] → [18][19][33] → [33][21][20] → [20][24]5 → 5[26]1 → 1[27]3 → 3[27][32] → [32][28][31] → [31][31][21] → [22]0C → C1[22] → [22]2D → D3[25] → [25]4[20] → [20]66 → 67[18] → [18]83 → 39D → D9[28] → [28]A[29] → [29]C[27] → [27]E[29] → [29][16][29] → [29][19]1 → 1[21]A → A[21][33] → [33][23]6 → 6[25][27] → [27][26][30] → [30][29]8 → 8[31][29] → [29][33]8 → 91[31] → [31]2[16] → [16]4C → C5E → E69 → 979 → 980 → 8[26] → [27]8 → 9[28] → [29]C → E2 → 2[30] → [31]0 → 1[28] → [28][30] → [32][18] → [20]E → F[20] → [21][16] → [17][24] → [25][24] → [26]6 → 7[24] → [25]4 → 5[20] → [20][30] → [32]2 → 3[32] → [33]4 → 62 → 2E → E[18] → [19]C → D[16] → [17]8 → 98 → 8[26] (1 leads to a 30-loop from 8[26] / 298 in base-34 at step 111; total steps = 141)

An alternative rule is to add the digit-sum first and then reverse the result. Now 8 becomes 8 + 8 = 16 and 16 becomes 61. Then 61 becomes 61 + 6 + 1 = 68 and 68 becomes 86. Then 86 becomes 86 + 8 + 6 = 100 and 100 becomes 001 = 1:

• 1 → 2 → 4 → 8 → 61 → 86 → 1
• 2 → 4 → 8 → 61 → 86 → 1 → 2
• 3 → 6 → 21 → 42 → 84 → 69 → 48 → 6
• 4 → 8 → 61 → 86 → 1 → 2 → 4
• 5 → 1 → 2 → 4 → 8 → 62 → 7 → 48 → 6 → 27 → 63 → 27
• 6 → 21 → 42 → 84 → 69 → 48 → 6
• 7 → 41 → 64 → 47 → 85 → 89 → 601 → 806 → 28 → 83 → 49 → 26 → 43 → 5 → 6 → 27 → 63 → 27
• 8 → 61 → 86 → 1 → 2 → 4 → 8
• 9 → 81 → 9
• 10 → 11 → 31 → 53 → 16 → 32 → 73 → 38 → 94 → 701 → 907 → 329 → 343 → 353 → 463 → 674 → 196 → 212 → 712 → 227 → 832 → 548 → 565 → 185 → 991 → 101 → 301 → 503 → 115 → 221 → 622 → 236 → 742 → 557 → 475 → 194→ 802 → 218 → 922 → 539 → 655 → 176 → 91 → 102 → 501 → 705 → 717 → 237 → 942 → 759 → 87 → 208 → 812 → 328 → 143 → 151 → 851 → 568 → 785 → 508 → 125 → 331 → 833 → 748 → 767 → 787 → 908 → 529 → 545 → 955 → 479 → 994 → 6102 → 1116 → 5211 → 225 → 432 → 144 → 351 → 63 → 27 → 63

Six Six Nix

4 x 3 = 13. A mistake? Not in base-9, where 13 = 1×9^1 + 3 = 12 in base-10. This means that 13 is a sum-product number in base-9: first add its digits, then multiply them, then multiply the digit-sum by the digit-product: (1+3) x (1×3) = 13[9]. There are four more sum-product numbers in this base:

2086[9] = 17 x 116 = (2 + 8 + 6) x (2 x 8 x 6) = 1536[10] = 16 x 96
281876[9] = 35 x 7333 = (2 + 8 + 1 + 8 + 7 + 6) x (2 x 8 x 1 x 8 x 7 x 6) = 172032[10] = 32 x 5376
724856[9] = 35 x 20383 = (7 + 2 + 4 + 8 + 5 + 6) x (7 x 2 x 4 x 8 x 5 x 6) = 430080[10] = 32 x 13440
7487248[9] = 44 x 162582 = (7 + 4 + 8 + 7 + 2 + 4 + 8) x (7 x 4 x 8 x 7 x 2 x 4 x 8) = 4014080[10] = 40 x 100352

And that’s the lot, apart from the trivial 0 = (0) x (0) and 1 = (1) x (1), which are true in all bases.

What about base-10?

135 = 9 x 15 = (1 + 3 + 5) x (1 x 3 x 5)
144 = 9 x 16 = (1 + 4 + 4) x (1 x 4 x 4)
1088 = 17 x 64 = (1 + 8 + 8) x (1 x 8 x 8)

1088 is missing from the list at Wikipedia and the Encyclopedia of Integer Sequences, but I like the look of it, so I’m including it here. Base-11 has five sum-product numbers:

419[11] = 13 x 33 = (4 + 1 + 9) x (4 x 1 x 9) = 504[10] = 14 x 36
253[11] = [10] x 28 = (2 + 5 + 3) x (2 x 5 x 3) = 300[10] = 10 x 30
2189[11] = 19 x 121 = (2 + 1 + 8 + 9) x (2 x 1 x 8 x 9) = 2880[10] = 20 x 144
7634[11] = 19 x 419 = (7 + 6 + 3 + 4) x (7 x 6 x 3 x 4) = 10080[10] = 20 x 504
82974[11] = 28 x 3036 = (8 + 2 + 9 + 7 + 4) x (8 x 2 x 9 x 7 x 4) = 120960[10] = 30 x 4032

But the record for bases below 50 is set by 7:

22[7] = 4 x 4 = (2 + 2) x (2 x 2) = 16[10] = 4 x 4
505[7] = 13 x 34 = (5 + 5) x (5 x 5) = 250[10] = 10 x 25
242[7] = 11 x 22 = (2 + 4 + 2) x (2 x 4 x 2) = 128[10] = 8 x 16
1254[7] = 15 x 55 = (1 + 2 + 5 + 4) x (1 x 2 x 5 x 4) = 480[10] = 12 x 40
2343[7] = 15 x 132 = (2 + 3 + 4 + 3) x (2 x 3 x 4 x 3) = 864[10] = 12 x 72
116655[7] = 33 x 2424 = (1 + 1 + 6 + 6 + 5 + 5) x (1 x 1 x 6 x 6 x 5 x 5) = 21600[10] = 24 x 900
346236[7] = 33 x 10362 = (3 + 4 + 6 + 2 + 3 + 6) x (3 x 4 x 6 x 2 x 3 x 6) = 62208[10] = 24 x 2592
424644[7] = 33 x 11646 = (4 + 2 + 4 + 6 + 4 + 4) x (4 x 2 x 4 x 6 x 4 x 4) = 73728[10] = 24 x 3072

And base-6? Six Nix. There are no sum-product numbers unique to that base (to the best of my far-from-infallible knowledge). Here is the full list for base-3 to base-50 (not counting 0 and 1 as sum-product numbers):

5 in base-11 4 in base-21 3 in base-31 2 in base-41
4 in base-12 5 in base-22 1 in base-32 3 in base-42
0 in base-3 3 in base-13 4 in base-23 3 in base-33 4 in base-43
2 in base-4 3 in base-14 2 in base-24 4 in base-34 5 in base-44
1 in base-5 2 in base-15 3 in base-25 2 in base-35 6 in base-45
0 in base-6 2 in base-16 6 in base-26 2 in base-36 7 in base-46
8 in base-7 6 in base-17 0 in base-27 3 in base-37 3 in base-47
1 in base-8 5 in base-18 1 in base-28 3 in base-38 7 in base-48
5 in base-9 7 in base-19 0 in base-29 1 in base-39 5 in base-49
3 in base-10 3 in base-20 2 in base-30 2 in base-40 3 in base-50

DeVil to Power

666 is the Number of the Beast described in the Book of Revelation:

13:18 Here is wisdom. Let him that hath understanding count the number of the beast: for it is the number of a man; and his number is Six hundred threescore and six.

But 666 is not just diabolic: it’s narcissistic too. That is, it mirrors itself using arithmetic, like this:

666^47 =

5,049,969,684,420,796,753,173,148,798,405,
  564,772,941,516,295,265,408,188,117,632,
  668,936,540,446,616,033,068,653,028,889,
  892,718,859,670,297,563,286,219,594,665,
  904,733,945,856 → 5 + 0 + 4 + 9 + 9 + 6 + 9 + 6 + 8 + 4 + 4 + 2 + 0 + 7 + 9 + 6 + 7 + 5 + 3 + 1 + 7 + 3 + 1 + 4 + 8 + 7 + 9 + 8 + 4 + 0 + 5 + 5 + 6 + 4 + 7 + 7 + 2 + 9 + 4 + 1 + 5 + 1 + 6 + 2 + 9 + 5 + 2 + 6 + 5 + 4 + 0 + 8 + 1 + 8 + 8 + 1 + 1 + 7 + 6 + 3 + 2 + 6 + 6 + 8 + 9 + 3 + 6 + 5 + 4 + 0 + 4 + 4 + 6 + 6 + 1 + 6 + 0 + 3 + 3 + 0 + 6 + 8 + 6 + 5 + 3 + 0 + 2 + 8 + 8 + 8 + 9 + 8 + 9 + 2 + 7 + 1 + 8 + 8 + 5 + 9 + 6 + 7 + 0 + 2 + 9 + 7 + 5 + 6 + 3 + 2 + 8 + 6 + 2 + 1 + 9 + 5 + 9 + 4 + 6 + 6 + 5 + 9 + 0 + 4 + 7 + 3 + 3 + 9 + 4 + 5 + 8 + 5 + 6 = 666

666^51 =

993,540,757,591,385,940,334,263,511,341,
295,980,723,858,637,469,431,008,997,120,
691,313,460,713,282,967,582,530,234,558,
214,918,480,960,748,972,838,900,637,634,
215,694,097,683,599,029,436,416 → 9 + 9 + 3 + 5 + 4 + 0 + 7 + 5 + 7 + 5 + 9 + 1 + 3 + 8 + 5 + 9 + 4 + 0 + 3 + 3 + 4 + 2 + 6 + 3 + 5 + 1 + 1 + 3 + 4 + 1 + 2 + 9 + 5 + 9 + 8 + 0 + 7 + 2 + 3 + 8 + 5 + 8 + 6 + 3 + 7 + 4 + 6 + 9 + 4 + 3 + 1 + 0 + 0 + 8 + 9 + 9 + 7 + 1 + 2 + 0 + 6 + 9 + 1 + 3 + 1 + 3 + 4 + 6 + 0 + 7 + 1 + 3 + 2 + 8 + 2 + 9 + 6 + 7 + 5 + 8 + 2 + 5 + 3 + 0 + 2 + 3 + 4 + 5 + 5 + 8 + 2 + 1 + 4 + 9 + 1 + 8 + 4 + 8 + 0 + 9 + 6 + 0 + 7 + 4 + 8 + 9 + 7 + 2 + 8 + 3 + 8 + 9 + 0 + 0 + 6 + 3 + 7 + 6 + 3 + 4 + 2 + 1 + 5 + 6 + 9 + 4 + 0 + 9 + 7 + 6 + 8 + 3 + 5 + 9 + 9 + 0 + 2 + 9 + 4 + 3 + 6 + 4 + 1 + 6 = 666

But those are tiny numbers compared to 6^(6^6). That means 6^46,656 and equals roughly 2·6591… x 10^36,305. It’s 36,306 digits long and its full digit-sum is 162,828. However, 666 lies concealed in those digits too. To see how, consider the function Σ(x1,xn), which returns the sum of digits 1 to n of x. For example, π = 3·14159265…, so Σ(π14) = 3 + 1 + 4 + 1 = 9. The first 150 digits of 6^(6^6) are these:

26591197721532267796824894043879185949053422002699
24300660432789497073559873882909121342292906175583
03244068282650672342560163577559027938964261261109
… (150 digits)

If x = 6^(6^6), then Σ(x1,x146) = 666, Σ(x2,x148) = 666, and Σ(x2,x149) = 666.

There’s nothing special about these patterns: infinitely many numbers are narcissistic in similar ways. However, 666 has a special cultural significance, so people pay it more attention and look for patterns related to it more carefully. Who cares, for example, that 667 = digit-sum(667^48) = digit-sum(667^54) = digit-sum(667^58)? Fans of recreational maths will, but not very much. The Number of the Beast is much more fun, narcissistically and otherwise:

666 = digit-sum(6^194)
666 = digit-sum(6^197)

666 = digit-sum(111^73)
666 = digit-sum(111^80)

666 = digit-sum(222^63)
666 = digit-sum(222^66)

666 = digit-sum(333^58)
666 = digit-sum(444^53)
666 = digit-sum(777^49)
666 = digit-sum(999^49)


Previously pre-posted (please peruse):

More Narcissisum
Digital Disfunction
The Hill to Power
Narcissarithmetic #1
Narcissarithmetic #2

More Narcissisum

The number 23 is special, inter alia, because it’s prime, divisible by only itself and 1. It’s also special because its reciprocal has maximum period. That is, the digits of 1/23 come in repeated blocks of 22, like this:

1/23 = 0·0434782608695652173913  0434782608695652173913  0434782608695652173913…

But 1/23 fails to be special in another way: you can’t sum its digits and get 23:

0 + 4 + 3 + 4 + 7 = 18
0 + 4 + 3 + 4 + 7 + 8 = 26
0 + 4 + 3 + 4 + 7 + 8 + 2 + 6 + 0 + 8 + 6 + 9 + 5 + 6 + 5 + 2 + 1 + 7 + 3 + 9 + 1 + 3 = 99

1/7 is different:

1/7 = 0·142857… → 1 + 4 + 2 = 7

This means that 7 is narcissistic: it reflects itself by manipulation of the digits of 1/7. But that’s in base ten. If you try base eight, 23 becomes narcissistic too (note that 23 = 2 x 8 + 7, so 23 in base eight is 27):

1/27 = 0·02620544131… → 0 + 2 + 6 + 2 + 0 + 5 + 4 + 4 = 27 (base=8)

Here are more narcissistic reciprocals in base ten:

1/3 = 0·3… → 3 = 3
1/7 = 0·142857… → 1 + 4 + 2 = 7
1/8 = 0·125 → 1 + 2 + 5 = 8
1/13 = 0·076923… → 0 + 7 + 6 = 13
1/14 = 0·0714285… → 0 + 7 + 1 + 4 + 2 = 14
1/34 = 0·02941176470588235… → 0 + 2 + 9 + 4 + 1 + 1 + 7 + 6 + 4 = 34
1/43 = 0·023255813953488372093… → 0 + 2 + 3 + 2 + 5 + 5 + 8 + 1 + 3 + 9 + 5 = 43
1/49 = 0·020408163265306122448979591836734693877551… → 0 + 2 + 0 + 4 + 0 + 8 + 1 + 6 + 3 + 2 + 6 + 5 + 3 + 0 + 6 + 1 + 2 = 49
1/51 = 0·0196078431372549… → 0 + 1 + 9 + 6 + 0 + 7 + 8 + 4 + 3 + 1 + 3 + 7 + 2 = 51
1/76 = 0·01315789473684210526… → 0 + 1 + 3 + 1 + 5 + 7 + 8 + 9 + 4 + 7 + 3 + 6 + 8 + 4 + 2 + 1 + 0 + 5 + 2 = 76
1/83 = 0·01204819277108433734939759036144578313253… → 0 + 1 + 2 + 0 + 4 + 8 + 1 + 9 + 2 + 7 + 7 + 1 + 0 + 8 + 4 + 3 + 3 + 7 + 3 + 4 + 9 = 83
1/92 = 0·010869565217391304347826… → 0 + 1 + 0 + 8 + 6 + 9 + 5 + 6 + 5 + 2 + 1 + 7 + 3 + 9 + 1 + 3 + 0 + 4 + 3 + 4 + 7 + 8 = 92
1/94 = 0·01063829787234042553191489361702127659574468085… → 0 + 1 + 0 + 6 + 3 + 8 + 2 + 9 + 7 + 8 + 7 + 2 + 3 + 4 + 0 + 4 + 2 + 5 + 5 + 3 + 1 + 9 + 1 + 4 = 94
1/98 = 0·0102040816326530612244897959183673469387755… → 0 + 1 + 0 + 2 + 0 + 4 + 0 + 8 + 1 + 6 + 3 + 2 + 6 + 5 + 3 + 0 + 6 + 1 + 2 + 2 + 4 + 4 + 8 + 9 + 7 + 9 + 5 = 98


Previously pre-posted (please peruse):

Digital Disfunction
The Hill to Power
Narcissarithmetic #1
Narcissarithmetic #2