# Sum of Digit squares

I like to create problems for myself, While playing with my calculator, I found the following result. Take any positive digit $a_0$, and let $a_n$ denote the sum of digit squares of $a_{n-1}$. Then there exists a $k$ such that $a_k=1$ or $4$.

(For a single digit number,$n$ take, $0^2+n^2$). I am not sure the result is true or false in general.

For example($a_0 = 679$)

$a_1=6^2+7^2+9^2=166$

$a_2=1^2+6^2+6^2=73$

$a_3=7^2+3^2=58$

$a_4=5^2+8^2=89$

$a_5=8^2+9^2=145$

$a_6=1^2+4^2+5^2=42$

$a_7=4^2+2^2=20$

$a_8=2^2+0^2=4$

Example 2($a_0=30$)

$a_1=3^2+0^2=9$

$a_2=0^2+9^2=81$

$a_3=8^2+1^2=65$

$a_4=6^2+5^2=61$

$a_5=6^2+1^2=37$

$a_6=3^2+7^2=58$

the rest is same

Even if the general result isn't true I would like to ask, why do most of the numbers behave this way?

• What is "a +ve integer"? – 5xum Apr 23 '14 at 7:55
• I don't get what you mean. – evil999man Apr 23 '14 at 7:56
• Any positive integer... – Tom Lynd Apr 23 '14 at 7:56
• @TomLynd Then I don't understand the question. If $a_k$ denotes the sum of digit squares of the positive integer $3$, then $a_k=9$ and $a_k\neq 1,4$. – 5xum Apr 23 '14 at 8:02
• @5xum I have updated the question – Tom Lynd Apr 23 '14 at 8:03

I believe this question can be solved as a combination of brute force and mathematics. It is simple to verify that your conjecture holds for $a_0<1000$ using a simple program, for example (written in Python):

for curr in range(1,1000):
s = set()
while True:
ints = [int(j)*int(j) for j in str(curr)]
curr = sum(ints)
if curr in s:
if 1 not in s and 4 not in s:
return False
break

Now all you have to show is that for any starting integer $a_0$, there exists such a $k$ that $a_k <1000$. This is simple to show since for $a_n>1000$, you can show that $a_{n+1} < a_n$:
Let $k$ be the number of digits of $a_n$. Then it is clear that $a_n>100k$, while on the other hand you know that $$a_{n+1} \leq 9^2+9^2+\dots+9^2=k\cdot 9^2\leq 100k<a_n.$$