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

Block and Goal

123456789. How many ways are there to insert + and – between the numbers and create a formula for 100? With pen and ink it takes a long time to answer. With programming, the answer will flash up in an instant:

01. 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100
02. 1 + 2 + 34 - 5 + 67 - 8 + 9 = 100
03. 1 + 23 - 4 + 5 + 6 + 78 - 9 = 100
04. 1 + 23 - 4 + 56 + 7 + 8 + 9 = 100
05. 12 - 3 - 4 + 5 - 6 + 7 + 89 = 100
06. 12 + 3 + 4 + 5 - 6 - 7 + 89 = 100
07. 12 + 3 - 4 + 5 + 67 + 8 + 9 = 100
08. 123 - 4 - 5 - 6 - 7 + 8 - 9 = 100
09. 123 + 4 - 5 + 67 - 89 = 100
10. 123 + 45 - 67 + 8 - 9 = 100
11. 123 - 45 - 67 + 89 = 100

And the beauty of programming is that you can easily generalize the problem to other bases. In base b, how many ways are there to insert + and – in the block [12345…b-1] to create a formula for b^2? When b = 10, the answer is 11. When b = 11, it’s 42. Here are two of those formulae in base-11:

123 - 45 + 6 + 7 - 8 + 9 + A = 100[b=11]
146 - 49 + 6 + 7 - 8 + 9 + 10 = 121

123 + 45 + 6 + 7 - 89 + A = 100[b=11]
146 + 49 + 6 + 7 - 97 + 10 = 121

When b = 12, it’s 51. Here are two of the formulae:

123 + 4 + 5 + 67 - 8 - 9A + B = 100[b=12]
171 + 4 + 5 + 79 - 8 - 118 + 11 = 144

123 + 4 + 56 + 7 - 89 - A + B = 100[b=12]
171 + 4 + 66 + 7 - 105 - 10 + 11 = 144

So that’s 11 formulae in base-10, 42 in base-11 and 51 in base-12. So what about base-13? The answer may be surprising: in base-13, there are no +/- formulae for 13^2 = 169 using the numbers 1 to 12. Nor are there any formulae in base-9 for 9^2 = 81 using the numbers 1 to 8. If you reverse the block, 987654321, the same thing happens. Base-10 has 15 formulae, base-11 has 54 and base-12 has 42. Here are some examples:

9 - 8 + 7 + 65 - 4 + 32 - 1 = 100
98 - 76 + 54 + 3 + 21 = 100

A9 + 87 - 65 + 4 - 3 - 21 = 100[b=11]
119 + 95 - 71 + 4 - 3 - 23 = 121

BA - 98 + 76 - 5 - 4 + 32 - 1 = 100[b=12]
142 - 116 + 90 - 5 - 4 + 38 - 1 = 144

But base-9 and base-13 again have no formulae. What’s going on? Is it a coincidence that 9 and 13 are each one more than a multiple of 4? No. Base-17 also has no formulae for b^2 = 13^2 = 169. Here is the list of formulae for bases-7 thru 17:

1, 2, 0, 11, 42, 51, 0, 292, 1344, 1571, 0 (block = 12345...)
3, 2, 0, 15, 54, 42, 0, 317, 1430, 1499, 0 (block = ...54321)

To understand what’s going on, consider any sequence of consecutive integers starting at 1. The number of odd integers in the sequence must always be greater than or equal to the number of even integers:

1, 2 (1 odd : 1 even)
1, 2, 3 (2 odds : 1 even)
1, 2, 3, 4 (2 : 2)
1, 2, 3, 4, 5 (3 : 2)
1, 2, 3, 4, 5, 6 (3 : 3)
1, 2, 3, 4, 5, 6, 7 (4 : 3)
1, 2, 3, 4, 5, 6, 7, 8 (4 : 4)

The odd numbers in a sequence determine the parity of the sum, that is, whether it is odd or even. For example:

1 + 2 = 3 (1 odd number)
1 + 2 + 3 = 6 (2 odd numbers)
1 + 2 + 3 + 4 = 10 (2 odd numbers)
1 + 2 + 3 + 4 + 5 = 15 (3 odd numbers)
1 + 2 + 3 + 4 + 5 + 6 = 21 (3 odd numbers)
1 + 2 + 3 + 4 + 5 + 6 + 7 = 28 (4 odd numbers)

If there is an even number of odd numbers, the sum will be even; if there is an odd number, the sum will be odd. Consider sequences that end in a multiple of 4:

1, 2, 3, 4 → 2 odds : 2 evens
1, 2, 3, 4, 5, 6, 7, 8 → 4 : 4
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 → 6 : 6

Such sequences always contain an even number of odd numbers. Now, consider these formulae in base-10:

1. 12 + 3 + 4 + 56 + 7 + 8 + 9 = 99
2. 123 - 45 - 67 + 89 = 100
3. 123 + 4 + 56 + 7 - 89 = 101

They can be re-written like this:

1. 1×10^1 + 2×10^0 + 3×10^0 + 4×10^0 + 5×10^1 + 6×10^0 + 7×10^0 + 8×10^0 + 9×10^0 = 99

2. 1×10^2 + 2×10^1 + 3×10^0 – 4×10^1 – 5×10^0 – 6×10^1 – 7×10^0 + 8×10^1 + 9×10^0 = 100

3. 1×10^2 + 2×10^1 + 3×10^0 + 4×10^0 + 5×10^1 + 6×10^1 + 7×10^0 – 8×10^1 – 9×10^0 = 101

In general, the base-10 formulae will take this form:

1×10^a +/- 2×10^b +/- 3×10^c +/– 4×10^d +/– 5×10^e +/– 6×10^f +/– 7×10^g +/– 8×10^h +/– 9×10^i = 100

It’s important to note that the exponent of 10, or the power to which it is raised, determines whether an odd number remains odd or becomes even. For example, 3×10^0 = 3×1 = 3, whereas 3×10^1 = 3×10 = 30 and 3×10^2 = 3×100 = 300. Therefore the number of odd numbers in a base-10 formula can vary and so can the parity of the sum. Now consider base-9. When you’re trying to find a block-formula for 9^2 = 81, the formula will have to take this form:

1×9^a +/- 2×9^b +/- 3×9^c +/- 4×9^d +/- 5×9^e +/- 6×9^f +/- 7×9^g +/- 8×9^h = 81

But no such formula exists for 81 (with standard exponents). It’s now possible to see why this is so. Unlike base-10, the odd numbers in the formula will remain odd what the power of 9. For example, 3×9^0 = 3×1 = 3, 3×9^1 = 3×9 = 27 and 3×9^2 = 3×81 = 243. Therefore base-9 formulae will always contain four odd numbers and will always produce an even number. Odd numbers in base-2 always end in 1, even numbers always end in 0. Therefore, to determine the parity of a sum of integers, convert the integers to base-2, discard all but the final digit of each integer, then sum the 1s. In a base-9 formula, these are the four possible results:

1 + 1 + 1 + 1 = 4
1 + 1 + 1 - 1 = 2
1 + 1 - 1 - 1 = 0
1 - 1 - 1 - 1 = -2

The sum represents the parity of the answer, which is always even. Similar reasoning applies to base-13, base-17 and all other base-[b=4n+1].

Persist List

Multiplicative persistence is a complex term but a simple concept. Take a number, multiply its digits, repeat. Sooner or later the result is a single digit:

25 → 2 x 5 = 10 → 1 x 0 = 0 (mp=2)
39 → 3 x 9 = 27 → 2 x 7 = 14 → 1 x 4 = 4 (mp=3)

So 25 has a multiplicative persistence of 2 and 39 a multiplicative persistence of 3. Each is the smallest number with that m.p. in base-10. Further records are set by these numbers:

77 → 49 → 36 → 18 → 8 (mp=4)
679 → 378 → 168 → 48 → 32 → 6 (mp=5)
6788 → 2688 → 768 → 336 → 54 → 20 → 0 (mp=6)
68889 → 27648 → 2688 → 768 → 336 → 54 → 20 → 0 (mp=7)
2677889 → 338688 → 27648 → 2688 → 768 → 336 → 54 → 20 → 0 (mp=8)
26888999 → 4478976 → 338688 → 27648 → 2688 → 768 → 336 → 54 → 20 → 0 (mp=9)
3778888999 → 438939648 → 4478976 → 338688 → 27648 → 2688 → 768 → 336 → 54 → 20 → 0 (mp=10)

Now here’s base-9:

25[b=9] → 11 → 1 (mp=2)
38[b=9] → 26 → 13 → 3 (mp=3)
57[b=9] → 38 → 26 → 13 → 3 (mp=4)
477[b=9] → 237 → 46 → 26 → 13 → 3 (mp=5)
45788[b=9] → 13255 → 176 → 46 → 26 → 13 → 3 (mp=6)
2577777[b=9] → 275484 → 13255 → 176 → 46 → 26 → 13 → 3 (mp=7)

And base-11:

26[b=11] → 11 → 1 (mp=2)
3A[b=11] → 28 → 15 → 5 (mp=3)
69[b=11] → 4A → 37 → 1A → A (=10b=10) (mp=4)
269[b=11] → 99 → 74 → 26 → 11 → 1 (mp=5)
3579[b=11] → 78A → 46A → 1A9 → 82 → 15 → 5 (mp=6)
26778[b=11] → 3597 → 78A → 46A → 1A9 → 82 → 15 → 5 (mp=7)
47788A[b=11] → 86277 → 3597 → 78A → 46A → 1A9 → 82 → 15 → 5 (mp=8)
67899AAA[b=11] → 143A9869 → 299596 → 2A954 → 2783 → 286 → 88 → 59 → 41 → 4 (mp=9)
77777889999[b=11] → 2AA174996A → 143A9869 → 299596 → 2A954 → 2783 → 286 → 88 → 59 → 41 → 4 (mp=10)

I was also interested in the narcissism of multiplicative persistence. That is, are any numbers equal to the sum of the numbers created while calculating their multiplicative persistence? Yes:

86 = (8 x 6 = 48) + (4 x 8 = 32) + (3 x 2 = 6)

I haven’t found any more in base-10 (apart from the trivial 0 to 9) and can’t prove that this is the only one. Base-9 offers this:

78[b=9] = 62 + 13 + 3

I can’t find any at all in base-11, but here are base-12 and base-27:

57[b=12] = 2B + 1A + A
A8[b=12] = 68 + 40 + 0

4[23][b=27] = 3B + 16 + 6
7[24][b=27] = 66 + 19 + 9
A[18][b=27] = 6[18] + 40 + 0
[26][24][b=27] = [23]3 + 2F + 13 + 3
[26][23][26][b=27] = [21]8[23] + 583 + 4C + 1[21] + [21]

But the richest base I’ve found so far is base-108, with fourteen narcissistic multiplicative-persistence sums:

4[92][b=108] = 3[44] + 1[24] + [24]
5[63][b=108] = 2[99] + 1[90] + [90]
7[96][b=108] = 6[24] + 1[36] + [36]
A[72][b=108] = 6[72] + 40 + 0
[19][81][b=108] = E[27] + 3[54] + 1[54] + [54]
[26][96][b=108] = [23]C + 2[60] + 1C + C
[35][81][b=108] = [26][27] + 6[54] + 30 + 0
[37][55][b=108] = [18][91] + F[18] + 2[54] + 10 + 0
[73][60][b=108] = [40][60] + [22][24] + 4[96] + 3[60] + 1[72] + [72]
[107][66][b=108] = [65][42] + [25][30] + 6[102] + 5[72] + 3[36] + 10 + 0
[71][84][b=108] = [55][24] + C[24] + 2[72] + 1[36] + [36]
[107][99][b=108] = [98]9 + 8[18] + 1[36] + [36]
5[92][96][b=108] = 3[84][96] + 280 + 0
8[107][100][b=108] = 7[36][64] + 1[41][36] + D[72] + 8[72] + 5[36] + 1[72] + [72]


Update (10/ii/14): The best now is base-180 with eighteen multiplicative-persistence sums.

5[105][b=180] = 2[165] + 1[150] + [150]
7[118][b=180] = 4[106] + 2[64] + [128]
7[160][b=180] = 6[40] + 1[60] + [60]
8[108][b=180] = 4[144] + 3[36] + [108]
A[120][b=180] = 6[120] + 40 + 0 (s=5)
[19][135][b=180] = E[45] + 3[90] + 1[90] + [90]
[21][108][b=180] = C[108] + 7[36] + 1[72] + [72]
[26][160][b=180] = [23][20] + 2[100] + 1[20] + [20]
[31][98][b=180] = [16][158] + E8 + [112]
[35][135][b=180] = [26][45] + 6[90] + 30 + 0 (s=10)
[44][96][b=180] = [23][84] + A[132] + 7[60] + 2[60] + [120]
[71][140][b=180] = [55][40] + C[40] + 2[120] + 1[60] + [60]
[73][100][b=180] = [40][100] + [22][40] + 4[160] + 3[100] + 1[120] + [120]
[107][110][b=180] = [65][70] + [25][50] + 6[170] + 5[120] + 3[60] + 10 + 0
[107][165][b=180] = [98]F + 8[30] + 1[60] + [60] (s=15)
[172][132][b=180] = [126][24] + [16][144] + C[144] + 9[108] + 5[72] + 20 + 0
5[173][145][b=180] = 3[156][145] + 2[17]0 + 0
E[170][120][b=180] = 8[146][120] + 4[58][120] + [154][120] + [102][120] + [68]0 + 0