2019 OIM Problems/Problem 1

Problem

For each positive integer $n$, let $s(n)$ be the sum of the squares of the digits of $n$. For example, $s(15) = 1^2 + 5^2 = 26$. Find all integers $n \ge 1$ such that $s(n) = n$.

~translated into English by Tomas Diaz. ~orders@tomasdiaz.com

Solution

Notice that if $n$ has $d$ digits, then $s(n)\le81d$ (by setting $n=\overline{999\dots999}$). Using this, we can easily show that the only possible values of $d$ are $d=1,2,3$ since any greater would cause $81d<10^d$, so the maximum value of $s(n)$ will always be less than the least possible value of $n$; thus $s(n)\ne n$.\\

Thus, we attempt casework on $d$. The case $d=1$ is trivial; only $n=1$ is a solution. Next, for $d=2$, we can show that the tens digit must always be even by considering parity of the ones digit versus parity of $s(n)$. Then, we can perform casework on the tens digit, which results in no solutions for this case.

Finally, we consider $d=3$. The maximum of $s(n)$ here is $9^2\cdot3=243$, so we can divide our work down. If the hundreds digit is $2$, then the maximum becomes $2^2+9^2+9^2=166<200$, so the hundreds digit must be $1$. Then we can perform casework on ones digit parity to show that the tens digit is always odd. Furthermore, the maximum in this case is $1^2+9^2+9^2=163$, so we only need to test the tens digit equal to $1,3,5$. These efforts result in no solutions, so $\boxed{n=1}$ is the only solution, which clearly works.

~ eevee9406

See also

OIM Problems and Solutions