Iterating sum of squares of decimal digits of an integer : how big can it grow

number theory

Let us first write an arbitrary natural number. For example, $$2538$$
Add the squares of its digits $$2^2 + 5^2 + 8^2 +3^2 = 102$$
Next, we do the same with the number obtained $$1^2 + 0^2 + 2^2 = 5$$
Proceed in the same way

\begin{align}
5^2&=25\\
2^2+5^2&=29\\
2^2+9^2&=85\\
8^2+5^2&=89\\
\vdots
\end{align}

Prove that unless this procedure leads to the number $1$ (in which case the number 1 will of course recur indefinitely, it must lead to the number $145$, and the following cycle will occur again and again: $$145, 42, 20, 4, 16 , 37, 58, 89$$

I asked myself the following questions: ''How big can the sum of squares of digits of a three-digit number be''? ''A four-digit number''? ''Can you show that for all sufficiently large numbers, the sum will always be smaller than the original number''?
How to prove it? I have no ideas

Best Answer

First, determine when the algorithm of summing squares of digits must give a result with fewer digits than the starting number. A number with $n$ digits cannot yield a sum of the squares of its digits greater than $81n$ and that happens when each digit is $9$. A number with $n$ digits is $>10^{n-1}$. So if $81n<10^{n-1}$, the algorithm will yield a number with fewer digits than the starting number. You can see that this occurs for $n\ge 4$ but not for $n=3$; $324<1000\text{ but }243>100$. So numbers with $4$ or more digits will yield shorter results, meaning any starting number will eventually arrive at a number with $3$ or fewer digits.

The largest possible three digit number is $999$, which yields $243$, so any number from $244$ to $999$ will yield a number of $243$ or smaller, therefore you only need concern yourself with numbers from $1$ to $243$. You could push this kind of analysis further, but there is no need. Once you have a number within that range, summing the squares of its digits will always yield another number within that range. If you repeat the algorithm $243$ or more times, either the resulting numbers will converge (as you suggest, to $1$), or there will have to be a repeat; more than $243$ results all within the first $243$ numbers means a repeat of some kind, either a convergence or a cycle, is forced. You have already identified such a cycle. The only open question is whether the cycle you identified is the only possible one.

Related Question