## Sum of cubes

### "Pick any old number you want . . . Now take all the digits and cube them and add the cubes together . . . Take that new number and do the same thing . . ."

Pat Ballew introduced this problem on his blog. G.H. Hardy said, there is nothing in [this] which appeals much to a mathematician. The proofs are neither difficult nor interesting . . ." Nevertheless, I thought it was worthy of some inspection, or at least a pretty picture.

It turns out that all terminal points or cycles are no more than four digits, so I explored all four-digit numbers. This is my first experiment with GraphViz, which is free. I made a graph; it appears below.
• Since 149, 491, 1490, and so on all go to the same place, I just thought of all of 24 permuatations of digits as one class and made it one node in the graph. For the rest of this exposition, I'll represent the class containing 149 as {149}.
• In the graph, unless it was an endpoint, each class is represented by the permuation with the smallest value.
• Negative numbers just denote that it takes one more step to really get to a terminal point or cycle. For example, 112 goes to 10 then to 1, which is represented by $$\{112\} \rightarrow \{-1\} \rightarrow \{1\}.$$ This ensures that any path has the correct length.
• The area of each node is proportional to the number of permutations; for example, {7} contains 7, 70, 700, or 7000, whereas {7777} contains one number.

#### So how many nodes are there?

$$\begin{array}{cccccc} \mbox{partition of }4 &\mbox {How many} \ldots & \mbox{ Classes of that type } & \times & \mbox{Numbers in each class } & = & \mbox{Numbers of that type} \\ 4 & 5 {10 \choose 1} - 1 & 9 & \times & 1 & = & 9 \\ 3+1 & 2 {10 \choose 2} & 90 & \times & 4 & = & 360 \\ 2+2 & {10 \choose 2} & 45 & \times & 6 & = & 270 \\ 2+1+1 & 3{10 \choose 3} & 360 & \times & 12 & = & 4320 \\ 1+1+1+1 & {10 \choose 4} & 210 & \times & 24 & = & 5040 \\ &\bf{Totals:}&\overline{714}&&&&\overline{9999} \\ \end{array}$$

#### Here are some fun facts

• The roots 1, 153, 370, 371, and 407 are Armstrong Numbers.
• In total, there are nine 'endgames.'
• By starting with 1, 2, 3, . . . , you learn them all when you reach 136.
• All cycles occur with numbers that are conguent to 1 (mod 3), but the converse isn't true because of the root 370.
• The longest paths all terminate at the root 153, starting with either {177}, {4467}, {4677}, or {4779}. This is probably expected since one-third of all numbers are in this tree.
• In terms of numbers, the biggest logjams occur at 856, 980, and 945, with three incoming edges $$( \mbox{i.e., } 178 \rightarrow 1^3 + 7^3 + 8^3 = 856, 1159 \rightarrow 856, \mbox{ and } 4468 \rightarrow 856).$$ The number 980 is a tail for 60 numbers, more than the others, including all elements in {578}, {1559}, and {2379}.
• In terms of classes, the biggest logjams in the graph occur at {18}, {125}, {127}, and {189}, each with ten heads of edges.
• Since classes like {459} and {1245} have lots of elements and feed into {127}, that logjam is probably most intense.
• Nine of the twelve elements of {18} are heads of some edge. This is the highest density for one class, matched by smaller classes {1}, which is a terminal point, and {8}.

#### And finally, the graph:

Click on the thumbnail to launch in a new window.

#### What if we considered all five digit numbers?

$$\begin{array}{cccccc} \mbox{partition of }5 &\mbox {How many} \ldots & \mbox{ Classes of that type } & \times & \mbox{Numbers in each class } & = & \mbox{Numbers of that type} \\ 5 & 5 {10 \choose 1} - 1 & 9 & \times & 1 & = & 9 \\ 4+1 & 2 {10 \choose 2} & 90 & \times & 5 & = & 450 \\ 3+2 & 2{10 \choose 2} & 90 & \times & 10 & = & 900 \\ 3+1+1 & 3{10 \choose 3} & 360 & \times & 20 & = & 7200 \\ 2+2+1 & 3{10 \choose 3} & 360 & \times & 30 & = & 10800 \\ 2+1+1+1 & 4{10 \choose 4} & 840 & \times & 60 & = & 50400 \\ 1+1+1+1+1 & {10 \choose 5} & 252^* & \times & 120 & = & 30240 \\ &\bf{Totals:}&\overline{2001}&&&&\overline{99999} \\ \end{array}$$ * - To generate these, I was excited, becuase I actually got to use the hockey-stick rule, $$\sum_{i=0}^{n} {i+k \choose k} = {n+1 \choose k+1}.$$

#### Tree sizes

How many numbers terminate with . . . 3 digit numbers 4 digit numbers 5 digit numbers
191001195
136, 24491601490
919, 1459243413070
407303963931
160, 217, 352514384140
55, 250, 133665185253
370174177618185
371303293729402
153333333333333