Can You Dij It? #1

The most powerful drug in the world is water. The second most powerful is language. But everyone’s on them, so nobody realizes how powerful they are. Well, you could stop drinking water. Then you’d soon realize its hold on the body and the brain.

But you can’t stop using language. Try it. No, the best way to realize the power of language is to learn a new one. Each is a feast with different flavours. New alphabets are good too. The Devanagari alphabet is one of the strongest, but if you want it in refined form, try the phonetic alphabet. It will transform the way you see the world. That’s because it will make you conscious of what you’re already subconsciously aware of.

But “language” is a bigger category that it used to be. Nowadays we have computer languages too. Learning one is another way of transforming the way you see the world. And like natural languages – French, Georgian, Tagalog – they come in different flavours. Pascal is not like Basic is not like C is not like Prolog. But all of them seem to put you in touch with some deeper aspect of reality. Computer languages are like mathemagick: a way to give commands to something immaterial and alter the world by the application of will.

That feeling is at its strongest when you program with machine code, the raw instructions used by the electronics of a computer. At its most fundamental, machine code is simply a series of binary numbers controlling how a computer processes other binary numbers. You can memorize and use those code-numbers, but it’s easier to use something like assembly language, which makes machine-code friendlier for human beings. But it still looks very odd to the uninitiated:

setupnum:
xor ax,ax
xor bp,bp
mov cx,20
clearloop:
mov [di+bp],ax
add bp,2
loop clearloop
ret

That’s almost at the binary bedrock. And machine code is fast. If a fast higher-level language like C feels like flying a Messerschmitt 262, which was a jet-plane, machine-code feels like flying a Messerschmitt 163, which was a rocket-plane. A very fast and very dangerous rocket-plane.

I’m not good at programming languages, least of all machine code, but they are fun to use, quite apart from the way they make you feel as though you’re in touch with a deeper aspect of reality. They do that because the world is mathematics at its most fundamental level, I think, and computer languages are a form of mathematics.

Their mathematical nature is disguised in a lot of what they’re used for, but I like to use them for recreational mathematics. Machine-code is useful when you need a lot of power and speed. For example, look at these digits:

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, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 3, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 5, 3, 6*, 3*, 7, 3, 8, 3, 9, 4, 0, 4, 1, 4, 2, 4…

They’re what the Online Encyclopedia of Integer Sequences (OEIS) calls “the almost natural numbers” (sequence A007376) and you generate them by writing the standard integers – 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13… – and then separating each digit with a comma: 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3… The commas give them some interesting twists. In a list of the standard integers, the 1st entry is 1, the 10th entry is 10, the 213rd entry is 213, the 987,009,381th entry is 987,009,381, and so on.

But that doesn’t work with the almost natural numbers. The 10th entry is 1, not 10, and the 11th entry is 0, not 11. But the 10th entry does begin the sequence (1, 0). I wondered whether that happened again. It does. The 63rd entry in the almost natural numbers begins the sequence (6, 3) – see the asterisks in the sequence above.

This happens again at the 3105th entry, which begins the sequence (3, 1, 0, 5). After that the gaps get bigger, which is where machine code comes in. An ordinary computer-language takes a long time to reach the 89,012,345,679th entry in the almost natural numbers. Machine code is much quicker, which is why I know that the 89,012,345,679th entry begins the sequence (8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 9):

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 63, 3105, 43108, 77781, 367573, 13859021, 77911127, 911360799, 35924813703, 74075186297, 89012345679…

And an ordinary computer-language might give you the impression that base 9 doesn’t have numbers like these (apart from the trivial 1, 2, 3, 4, 5, 6, 7, 8, 10…). But it does. 63 in base 10 is a low-hanging fruit: you could find it working by hand. In base 9, the fruit are much higher-hanging. But machine code plucks them with almost ridiculous ease:

1, 2, 3, 4, 5, 6, 7, 8, 10, 570086565, 655267526, 2615038272, 4581347024, 5307541865, 7273850617, 7801234568…

Narcischism

What have bits to do with splits? A lot. Suppose you take the digits 12345, split them in all possible ways, then sum the results, like this:

12345 → (1234 + 5) + (123 + 45) + (123 + 4 + 5) + (12 + 345) + (12 + 34 + 5) + (12 + 3 + 45) + (12 + 3 + 4 + 5) + (1 + 2345) + (1 + 234 + 5) + (1 + 23 + 45) + (1 + 23 + 4 + 5) + (1 + 2 + 345) + (1 + 2 + 34 + 5) + (1 + 2 + 3 + 45) + (1 + 2 + 3 + 4 + 5) = 5175.

That’s a sum in base 10, but base 2 is at work below the surface, because each set of numbers is the answer to a series of binary questions: split or not? There are four possible places to split the digits 12345: after the 1, after the 2, after the 3 and after the 4. In (1 + 2 + 3 + 4 + 5), the binary question “Split or not?” is answered SPLIT every time. In (1234 + 5) and (1 + 2345) it’s answered SPLIT only once.

So the splits are governed by a four-digit binary number ranging from 0001 to 1111. When the binary digit is 1, split; when the binary digit is 0, don’t split. In binary, 0001 to 1111 = 01 to 15 in base 10 = 2^4-1. That’s for a five-digit number, so the four-digit 1234 will have 2^3-1 = 7 sets of sums:

1234 → (123 + 4) + (12 + 34) + (12 + 3 + 4) + (1 + 234) + (1 + 23 + 4) + 110 (1 + 2 + 34) + (1 + 2 + 3 + 4) = 502.

And the six-digit number 123456 will have 2^5-1 = 31 sets of sums. By now, an exciting question may have occurred to some readers. Does any number in base 10 equal the sum of all possible numbers formed by splitting its digits?

The exciting answer is: 0. In other words: No. To see why not, examine a quick way of summing the split-bits of 123,456,789, with nine digits. The long way is to find all possible sets of split-bits. There are 2^8-1 = 255 of them. The quick way is to sum these equations:

1 * 128 + 10 * 64 + 100 * 32 + 1000 * 16 + 10000 * 8 + 100000 * 4 + 1000000 * 2 + 10000000 * 1
2 * 128 + 20 * 64 + 200 * 32 + 2000 * 16 + 20000 * 8 + 200000 * 4 + 2000000 * 2 + 20000000 * 1
3 * 128 + 30 * 64 + 300 * 32 + 3000 * 16 + 30000 * 8 + 300000 * 4 + 3000000 * 3
4 * 128 + 40 * 64 + 400 * 32 + 4000 * 16 + 40000 * 8 + 400000 * 7
5 * 128 + 50 * 64 + 500 * 32 + 5000 * 16 + 50000 * 15
6 * 128 + 60 * 64 + 600 * 32 + 6000 * 31
7 * 128 + 70 * 64 + 700 * 63
8 * 128 + 80 * 127
9 * 255

Sum = 52,322,283.

52,322,283 has eight digits. If you use the same formula for the nine-digit number 999,999,999, the sum is 265,621,761, which has nine digits but is far smaller than 999,999,999. If you adapt the formula for the twenty-digit 19,999,999,999,999,999,999 (starting with 1), the split-bit sum is 16,562,499,999,987,400,705. In base 10, as far as I can see, numbers increase too fast and digit-lengths too slowly for the binary governing the split-sums to keep up. That’s also true in base 9 and base 8:

Num = 18,888,888,888,888,888,888 (b=9)
Sum = 16,714,201,578,038,328,760

Num = 17,777,777,777,777,777,777 (b=8)
Sum = 17,070,707,070,625,000,001

So what about base 7? Do the numbers increase slowly enough and the digit-lengths fast enough for the binary to keep up? The answer is: 1. In base 7, this twenty-digit number is actually smaller than its split-bit sum:

Num = 16,666,666,666,666,666,666 (b=7)
Sum = 20,363,036,303,404,141,363

And if you search below that, you can find a number that is equal to its split-bit sum:

166512 → (1 + 6 + 6 + 5 + 1 + 2) + (16 + 6 + 5 + 1 + 2) + (1 + 66 + 5 + 1 + 2) + (166 + 5 + 1 + 2) + (1 + 6 + 65 + 1 + 2) + (16 + 65 + 1 + 2) + (1 + 665 + 1 + 2) + (1665 + 1 + 2) + (1 + 6 + 6 + 51 + 2) + (16 + 6 + 51 + 2) + (1 + 66 + 51 + 2) + (166 + 51 + 2) + (1 + 6 + 651 + 2) + (16 + 651 + 2) + (1 + 6651 + 2) + (16651 + 2) + (1 + 6 + 6 + 5 + 12) + (16 + 6 + 5 + 12) + (1 + 66 + 5 + 12) + (166 + 5 + 12) + (1 + 6 + 65 + 12) + (16 + 65 + 12) + (1 + 665 + 12) + (1665 + 12) + (1 + 6 + 6 + 512) + (16 + 6 + 512) + (1 + 66 + 512) + (166 + 512) + (1 + 6 + 6512) + (16 + 6512) + (1 + 66512) = 166512[b=7] = 33525[b=10].

So 33525 in base 7 is what might be called a narcischist: it can gaze into the split-bits of its own digits and see itself gazing back. In base 6, 1940 is a narcischist:

12552 → (1 + 2 + 5 + 5 + 2) + (12 + 5 + 5 + 2) + (1 + 25 + 5 + 2) + (125 + 5 + 2) + (1 + 2 + 55 + 2) + (12 + 55 + 2) + (1 + 255 + 2) + (1255 + 2) + (1 + 2 + 5+ 52) + (12 + 5 + 52) + (1 + 25 + 52) + (125 + 52) + (1 + 2 + 552) + (12 + 552) + (1 + 2552) = 12552[b=6] = 1940[b=10].

In base 5, 4074 is a narcischist:

112244 → (1 + 1 + 2 + 2 + 4 + 4) + (11 + 2 + 2 + 4 + 4) + (1 + 12 + 2 + 4 + 4) + (112 + 2 + 4 + 4) + (1 + 1 + 22 + 4 + 4) + (11 + 22 + 4 + 4) + (1 + 122 + 4 + 4) + (1122 + 4 + 4) + (1 + 1 + 2 + 24 + 4) + (11 + 2 + 24 + 4) + (1 + 12 + 24 + 4) + (112 + 24 + 4) + (1 + 1 + 224 + 4) + (11 + 224 + 4) + (1 + 1224 + 4) + (11224 + 4) + (1 + 1 + 2 + 2 + 44) + (11 + 2 + 2 + 44) + (1 + 12 + 2 + 44) + (112 + 2 + 44) + (1 + 1 + 22 + 44) + (11 + 22 + 44) + (1 + 122 + 44) + (1122 + 44) + (1 + 1 + 2 + 244) + (11 + 2 + 244) + (1 + 12 + 244) + (112 + 244) + (1 + 1 + 2244) + (11 + 2244) + (1 + 12244) = 112244[b=5] = 4074.

And in base 4, 27 is:

123 → (1 + 2 + 3) + (12 + 3) + (1 + 23) = 123[b=4] = 27.

And in base 3, 13 and 26 are:

111 → (1 + 1 + 1) + (11 + 1) + (1 + 11) = 111[b=3] = 13.

222 → (2 + 2 + 2) + (22 + 2) + (2 + 22) = 222[b=3] = 26.

There are many more narcischists in all these bases, even if you exclude numbers with zeroes in them, like these in base 4:

1022 → (1 + 0 + 2 + 2) + (10 + 2 + 2) + (1 + 02 + 2) + (102 + 2) + (1 + 0 + 22) + (10 + 22) + (1 + 022) = 1022[b=4] = 74.

1030 → (1 + 0 + 3 + 0) + (10 + 3 + 0) + (1 + 03 + 0) + (103 + 0) + (1 + 0 + 30) + (10 + 30) + (1 + 030) = 1030[b=4] = 76.

1120 → (1 + 1 + 2 + 0) + (11 + 2 + 0) + (1 + 12 + 0) + (112 + 0) + (1 + 1 + 20) + (11 + 20) + (1 + 120) = 1120[b=4] = 88.

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

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

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

Narcissarithmetic #2

It’s easy to find patterns like these in base ten:

81 = (8 + 1)^2 = 9^2 = 81

512 = (5 + 1 + 2)^3 = 8^3 = 512
4913 = (4 + 9 + 1 + 3)^3 = 17^3 = 4913
5832 = (5 + 8 + 3 + 2)^3 = 18^3 = 5832
17576 = (1 + 7 + 5 + 7 + 6)^3 = 26^3 = 17576
19683 = (1 + 9 + 6 + 8 + 3)^3 = 27^3 = 19683

2401 = (2 + 4 + 0 + 1)^4 = 7^4 = 2401
234256 = (2 + 3 + 4 + 2 + 5 + 6)^4 = 22^4 = 234256
390625 = (3 + 9 + 0 + 6 + 2 + 5)^4 = 25^4 = 390625
614656 = (6 + 1 + 4 + 6 + 5 + 6)^4 = 28^4 = 614656
1679616 = (1 + 6 + 7 + 9 + 6 + 1 + 6)^4 = 36^4 = 1679616

17210368 = (1 + 7 + 2 + 1 + 0 + 3 + 6 + 8)^5 = 28^5 = 17210368
52521875 = (5 + 2 + 5 + 2 + 1 + 8 + 7 + 5)^5 = 35^5 = 52521875
60466176 = (6 + 0 + 4 + 6 + 6 + 1 + 7 + 6)^5 = 36^5 = 60466176
205962976 = (2 + 0 + 5 + 9 + 6 + 2 + 9 + 7 + 6)^5 = 46^5 = 205962976

1215766545905692880100000000000000000000 = (1 + 2 + 1 + 5 + 7 + 6 + 6 + 5 + 4 + 5 + 9 + 0 + 5 + 6 + 9 + 2 + 8 + 8 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0)^20 = 90^20 = 1215766545905692880100000000000000000000

Patterns like this are much rarer:

914457600 = (9 x 1 x 4 x 4 x 5 x 7 x 6)^2 = 30240^2 = 914457600

3657830400 = (3 x 6 x 5 x 7 x 8 x 3 x 4)^2 = 60480^2 = 3657830400

I haven’t found a cube like that in base ten, but base six supplies them:

2212 = (2 x 2 x 1 x 2)^3 = 12^3 = 2212 (b=6) = 8^3 = 512 (b=10)
325000 = (3 x 2 x 5)^3 = 50^3 = 325000 (b=6) = 30^3 = 27000 (b=10)
411412 = (4 x 1 x 1 x 4 x 1 x 2)^3 = 52^3 = 411412 (b=6) = 32^3 = 32768 (b=10)

And base nine supplies a fourth and fifth power:

31400 = (3 x 1 x 4)^4 = 13^4 = 31400 (b=9) = 12^4 = 20736 (b=10)
11600 = (1 x 1 x 6)^5 = 6^5 = 11600 (b=9) = 6^5 = 7776 (b=10)

Then base ten is rich in patterns like these:

81 = (8^1 + 1^1) x (8 + 1) = 9 x 9 = 81

133 = (1^2 + 3^2 + 3^2) x (1 + 3 + 3) = 19 x 7 = 133
315 = (3^2 + 1^2 + 5^2) x (3 + 1 + 5) = 35 x 9 = 315
803 = (8^2 + 0^2 + 3^2) x (8 + 0 + 3) = 73 x 11 = 803
1148 = (1^2 + 1^2 + 4^2 + 8^2) x (1 + 1 + 4 + 8) = 82 x 14 = 1148
1547 = (1^2 + 5^2 + 4^2 + 7^2) x (1 + 5 + 4 + 7) = 91 x 17 = 1547
2196 = (2^2 + 1^2 + 9^2 + 6^2) x (2 + 1 + 9 + 6) = 122 x 18 = 2196

1215 = (1^3 + 2^3 + 1^3 + 5^3) x (1 + 2 + 1 + 5) = 135 x 9 = 1215
3700 = (3^3 + 7^3 + 0^3 + 0^3) x (3 + 7 + 0 + 0) = 370 x 10 = 3700
11680 = (1^3 + 1^3 + 6^3 + 8^3 + 0^3) x (1 + 1 + 6 + 8 + 0) = 730 x 16 = 11680
13608 = (1^3 + 3^3 + 6^3 + 0^3 + 8^3) x (1 + 3 + 6 + 0 + 8) = 756 x 18 = 13608
87949 = (8^3 + 7^3 + 9^3 + 4^3 + 9^3) x (8 + 7 + 9 + 4 + 9) = 2377 x 37 = 87949

182380 = (1^4 + 8^4 + 2^4 + 3^4 + 8^4 + 0^4) x (1 + 8 + 2 + 3 + 8 + 0) = 8290 x 22 = 182380
444992 = (4^4 + 4^4 + 4^4 + 9^4 + 9^4 + 2^4) x (4 + 4 + 4 + 9 + 9 + 2) = 13906 x 32 = 444992

41500 = (4^5 + 1^5 + 5^5 + 0^5 + 0^5) x (4 + 1 + 5 + 0 + 0) = 4150 x 10 = 41500
3508936 = (3^5 + 5^5 + 0^5 + 8^5 + 9^5 + 3^5 + 6^5) x (3 + 5 + 0 + 8 + 9 + 3 + 6) = 103204 x 34 = 3508936
3828816 = (3^5 + 8^5 + 2^5 + 8^5 + 8^5 + 1^5 + 6^5) x (3 + 8 + 2 + 8 + 8 + 1 + 6) = 106356 x 36 = 3828816
4801896 = (4^5 + 8^5 + 0^5 + 1^5 + 8^5 + 9^5 + 6^5) x (4 + 8 + 0 + 1 + 8 + 9 + 6) = 133386 x 36 = 4801896
5659875 = (5^5 + 6^5 + 5^5 + 9^5 + 8^5 + 7^5 + 5^5) x (5 + 6 + 5 + 9 + 8 + 7 + 5) = 125775 x 45 = 5659875


Previously pre-posted (please peruse):

Narcissarithmetic

Narcissarithmetic

Why is 438,579,088 a beautiful number? Simple: it may seem entirely arbitrary, but it’s actually self-empowered:

438,579,088 = 4^4 + 3^3 + 8^8 + 5^5 + 7^7 + 9^9 + 0^0 + 8^8 + 8^8 = 256 + 27 + 16777216 + 3125 + 823543 + 387420489 + 0 + 16777216 + 16777216 (usually 0^0 = 1, but the rule is slightly varied here)

438,579,088 is so beautiful, in fact, that it’s in love with itself as a narcissistic number, or number that can be generated by manipulation of its own digits. 89 = 8^1 + 9^2 = 8 + 81 and 135 = 1^1 + 3^2 + 5^3 = 1 + 9 + 125 are different kinds of narcissistic number. 3435 is self-empowered again:

3435 = 3^3 + 4^4 + 3^3 + 5^5 = 27 + 256 + 27 + 3125

But that’s your lot: there are no more numbers in base-10 that are equal to the sum of their self-empowered digits (apart from the trivial 0 and 1). To prove this, start by considering that there is a limit to the size of a self-empowered number. 9^9 is 387,420,489, which is nine digits long. The function autopower(999,999,999) = 387,420,489 x 9 = 3,486,784,401, which is ten digits long. But autopower(999,999,999,999) = 387,420,489 x 12 = 4,649,045,868, also ten digits long.

The Metamorphosis of Narcissus by Salvador Dalí

Salvador Dalí, La Metamorfosis de Narciso (1937)

So you don’t need to check numbers above a certain size. There still seem a lot of numbers to check: 438,579,088 is a long way above 3435. However, the search is easy to shorten if you consider that checking 3-3-4-5 is equivalent to checking 3-4-3-5, just as checking 034,578,889 is equivalent to checking 438,579,088. If you self-empower a number and the result has the same digits as the original number, you’ve found what you’re looking for. The order of digits in the original number doesn’t matter, because the result has automatically sorted them for you. The function autopower(3345) produces 3435, therefore 3435 must be self-empowered.

So the rule is simple: Check only the numbers in which any digit is greater than or equal to all digits to its left. In other words, you check 12 and skip 21, check 34 and skip 43, check 567 and skip 576, 657, 675, 756 and 765. That reduces the search-time considerably: discarding numbers is computationally simpler than self-empowering them. It’s also computationally simple to vary the base in which you’re searching. Base-10 produces only two self-empowered numbers, but its neighbours base-9 and base-11 are much more fertile:

30 = 3^3 + 0^0 = 30 + 0 (b=9)
27 = 27 + 0 (b=10)

31 = 3^3 + 1^1 = 30 + 1 (b=9)
28 = 27 + 1 (b=10)

156262 = 1^1 + 5^5 + 6^6 + 2^2 + 6^6 + 2^2 = 1 + 4252 + 71000 + 4 + 71000 + 4 (b=9)
96446 = 1 + 3125 + 46656 + 4 + 46656 + 4 (b=10)

1647063 = 1^1 + 6^6 + 4^4 + 7^7 + 0^0 + 6^6 + 3^3 = 1 + 71000 + 314 + 1484617 + 0 + 71000 + 30 (b=9)
917139 = 1 + 46656 + 256 + 823543 + 0 + 46656 + 27 (b=10)

1656547 = 1^1 + 6^6 + 5^5 + 6^6 + 5^5 + 4^4 + 7^7 = 1 + 71000 + 4252 + 71000 + 4252 + 314 + 1484617 (b=9)
923362 = 1 + 46656 + 3125 + 46656 + 3125 + 256 + 823543 (b=10)

34664084 = 3^3 + 4^4 + 6^6 + 6^6 + 4^4 + 0^0 + 8^8 + 4^4 = 30 + 314 + 71000 + 71000 + 314 + 0 + 34511011 + 314 (b=9)
16871323 = 27 + 256 + 46656 + 46656 + 256 + 0 + 16777216 + 256 (b=10)

66500 = 6^6 + 6^6 + 5^5 + 0^0 + 0^0 = 32065 + 32065 + 2391 + 0 + 0 (b=11)
96437 = 46656 + 46656 + 3125 + 0 + 0 (b=10)

66501 = 6^6 + 6^6 + 5^5 + 0^0 + 1^1 = 32065 + 32065 + 2391 + 0 + 1 (b=11)
96438 = 46656 + 46656 + 3125 + 0 + 1 (b=10)

517503 = 5^5 + 1^1 + 7^7 + 5^5 + 0^0 + 3^3 = 2391 + 1 + 512816 + 2391 + 0 + 25 (b=11)
829821 = 3125 + 1 + 823543 + 3125 + 0 + 27 (b=10)

18453278 = 1^1 + 8^8 + 4^4 + 5^5 + 3^3 + 2^2 + 7^7 + 8^8 = 1 + 9519A75 + 213 + 2391 + 25 + 4 + 512816 + 9519A75 (b=11)
34381388 = 1 + 16777216 + 256 + 3125 + 27 + 4 + 823543 + 16777216 (b=10)

18453487 = 1^1 + 8^8 + 4^4 + 5^5 + 3^3 + 4^4 + 8^8 + 7^7 = 1 + 9519A75 + 213 + 2391 + 25 + 213 + 9519A75 + 512816 (b=11)
34381640 = 1 + 16777216 + 256 + 3125 + 27 + 256 + 16777216 + 823543 (b=10)

It’s easy to extend the concept of self-empowered narcisso-numbers. The prime 71 = 131 in base-7 and the prime 83 = 146 in base-7. If 131[b=7] is empowered to the digits of 146[b=7], you get 146[b=7]; and if 146[b=7] is empowered to the digits of 131[b=7], you get 131[b=7], like this:

71 = 131[b=7] → 1^1 + 3^4 + 1^6 = 1 + 81 + 1 = 83 = 146[b=7]

83 = 146[b=7] → 1^1 + 4^3 + 6^1 = 1 + 64 + 6 = 71 = 131[b=7]

But it’s not easy to find more examples. Are there other-empowering pairs like that in base-10? I don’t know.

Factory Records

The factors of n are those numbers that divide n without remainder. So the factors of 6 are 1, 2, 3 and 6. If the function s(n) is defined as “the sum of the factors of n, excluding n, then s(6) = 1 + 2 + 3 = 6. This makes 6 a perfect number: its factors re-create it. 28 is another perfect number. The factors of 28 are 1, 2, 4, 7, 14 and 28, so s(28) = 1 + 2 + 4 + 7 + 14 = 28. Other perfect numbers are 496 and 8128. And they’re perfect in any base.

Amicable numbers are amicable in any base too. The factors of an amicable number sum to a second number whose factors sum to the first number. So s(220) = 284, s(284) = 220. That pair may have been known to Pythagoras (c.570-c.495 BC), but s(1184) = 1210, s(1210) = 1184 was discovered by an Italian schoolboy called Nicolò Paganini in 1866. There are also sociable chains, in which s(n), s(s(n)), s(s(s(n))) create a chain of numbers that leads back to n, like this:

12496 → 14288 → 15472 → 14536 → 14264 → 12496 (c=5)

Or this:

14316 → 19116 → 31704 → 47616 → 83328 → 177792 → 295488 → 629072 → 589786 → 294896 → 358336 → 418904 → 366556 → 274924 → 275444 → 243760 → 376736 → 381028 → 285778 → 152990 → 122410 → 97946 → 48976 → 45946 → 22976 → 22744 → 19916 → 17716 → 14316 (c=28)

Those sociable chains were discovered (and christened) in 1918 by the Belgian mathematician Paul Poulet (1887-1946). Other factor-sum patterns are dependant on the base they’re expressed in. For example, s(333) = 161. So both n and s(n) are palindromes in base-10. Here are more examples — the numbers in brackets are the prime factors of n and s(n):

333 (3^2, 37) → 161 (7, 23)
646 (2, 17, 19) → 434 (2, 7, 31)
656 (2^4, 41) → 646 (2, 17, 19)
979 (11, 89) → 101 (prime)
1001 (7, 11, 13) → 343 (7^3)
3553 (11, 17, 19) → 767 (13, 59)
10801 (7, 1543) → 1551 (3, 11, 47)
11111 (41, 271) → 313 (prime)
18581 (17, 1093) → 1111 (11, 101)
31713 (3, 11, 31^2) → 15951 (3, 13, 409)
34943 (83, 421) → 505 (5, 101)
48484 (2^2, 17, 23, 31) → 48284 (2^2, 12071)
57375 (3^3, 5^3, 17) → 54945 (3^3, 5, 11, 37)
95259 (3, 113, 281) → 33333 (3, 41, 271)
99099 (3^2, 7, 11^2, 13) → 94549 (7, 13, 1039)
158851 (7, 11, 2063) → 39293 (prime)
262262 (2, 7, 11, 13, 131) → 269962 (2, 7, 11, 1753)
569965 (5, 11, 43, 241) → 196691 (11, 17881)
1173711 (3, 7, 11, 5081) → 777777 (3, 7^2, 11, 13, 37)

Note how s(656) = 646 and s(646) = 434. There’s an even longer sequence in base-495:

33 → 55 → 77 → 99 → [17][17] → [19][19] → [21][21] → [43][43] → [45][45] → [111][111] → [193][193] → [195][195] → [477][477] (b=495) (c=13)
1488 (2^4, 3, 31) → 2480 (2^4, 5, 31) → 3472 (2^4, 7, 31) → 4464 (2^4, 3^2, 31) → 8432 (2^4, 17, 31) → 9424 (2^4, 19, 31) → 10416 (2^4, 3, 7, 31) → 21328 (2^4, 31, 43) → 22320 (2^4, 3^2, 5, 31) → 55056 (2^4, 3, 31, 37) → 95728 (2^4, 31, 193) → 96720 (2^4, 3, 5, 13, 31) → 236592 (2^4, 3^2, 31, 53)

I also tried looking for n whose s(n) mirrors n. But they’re hard to find in base-10. The first example is this:

498906 (2, 3^3, 9239) → 609894 (2, 3^2, 31, 1093)

498906 mirrors 609894, because the digits of each run in reverse to the digits of the other. Base-9 does better for mirror-sums, clocking up four in the same range of integers:

42 → 24 (base=9)
38 (2, 19) → 22 (2, 11)
402 → 204 (base=9)
326 (2, 163) → 166 (2, 83)
4002 → 2004 (base=9)
2918 (2, 1459) → 1462 (2, 17, 43)
5544 → 4455 (base=9)
4090 (2, 5, 409) → 3290 (2, 5, 7, 47)

Base-11 does better still, clocking up eight in the same range:

42 → 24 (base=11)
46 (2, 23) → 26 (2, 13)
2927 → 7292 (base=11)
3780 (2^2, 3^3, 5, 7) → 9660 (2^2, 3, 5, 7, 23)
4002 → 2004 (base=11)
5326 (2, 2663) → 2666 (2, 31, 43)
13772 → 27731 (base=11)
19560 (2^3, 3, 5, 163) → 39480 (2^3, 3, 5, 7, 47)
4[10]7[10]9 → 9[10]7[10]4 (base=11)
72840 (2^3, 3, 5, 607) → 146040 (2^3, 3, 5, 1217)
6929[10] → [10]9296 (base=11)
100176 (2^4, 3, 2087) → 158736 (2^4, 3, 3307)
171623 → 326171 (base=11)
265620 (2^2, 3, 5, 19, 233) → 520620 (2^2, 3, 5, 8677)
263702 → 207362 (base=11)
414790 (2, 5, 41479) → 331850 (2, 5^2, 6637)

Note that 42 mirrors its factor-sum in both base-9 and base-11. But s(42) = 24 in infinitely many bases, because when 42 = 2 x prime, s(42) = 1 + 2 + prime. So (prime-1) / 2 will give the base in which 24 = s(42). For example, 2 x 11 = 22 and 22 = 42 in base (11-1) / 2 or base-5. So s(42) = 1 + 2 + 11 = 14 = 2 x 5 + 4 = 24[b=5]. There are infinitely many primes, so infinitely many bases in which s(42) = 24.

Base-10 does better for mirror-sums when s(n) is re-defined to include n itself. So s(69) = 1 + 3 + 23 + 69 = 96. Here are the first examples of all-factor mirror-sums in base-10:

69 (3, 23) → 96 (2^5, 3)
276 (2^2, 3, 23) → 672 (2^5, 3, 7)
639 (3^2, 71) → 936 (2^3, 3^2, 13)
2556 (2^2, 3^2, 71) → 6552 (2^3, 3^2, 7, 13)

In the same range, base-9 now produces one mirror-sum, 13 → 31 = 12 (2^2, 3) → 28 (2^2, 7). Base-11 produces no mirror-sums in the same range. Base behaviour is eccentric, but that’s what makes it interesting.