
3. For any natural number $n$, expressed in base 10, let $s(n)$ denote the sum of all its digits. Find all natural numbers $m$ and $n$ such that $m<n$ and

$$
(s(n))^{2}=m \quad \text { and } \quad(s(m))^{2}=n
$$


## Solution

Let $m<n$ be such natural numbers. Let

$$
m=10^{k-1} a_{k-1}+10^{k-2} a_{k-2}+\cdots+10 a_{1}+a_{0}
$$

be a $k$-digit number. Then we have

$$
10^{k-1} \leq m<n=s(m)^{2}=\left(a_{k-1}+a_{k-2}+\cdots+a_{1}+a_{0}\right)^{2} \leq 9^{2} k^{2}
$$

If $k \geq 5$, this is not possible. Hence $k \leq 4$.

If $k=4$, then

$$
m=1000 a_{3}+100 a_{2}+10 a_{1}+a_{0}<\left(a_{3}+a_{2}+a_{1}+a_{0}\right)^{2} \leq 36^{2}=1296
$$

This shows that $a_{3}=1$. In this case

$$
m=1000+100 a_{2}+10 a_{1}+a_{0}<\left(1+a_{2}+a_{1}+a_{0}\right)^{2} \leq 28^{2}=784
$$

which is impossible. Hence $m$ must be a 3-digit number. Again

$$
m=100 a_{2}+10 a_{1}+a_{0}<\left(a_{2}+a_{1}+a_{0}\right)^{2} \leq 27^{2}=729
$$

Hence $a_{2} \leq 7$. If $a_{2}=7$, then

$$
m=700+10 a_{1}+a_{0}<\left(7+a_{1}+a_{0}\right)^{2} \leq 25^{2}=625
$$

which is not possible. Similarly, $a_{2}=6$ gives

$$
m=600+10 a_{1}+a_{0}<\left(6+a_{1}+a_{0}\right)^{2} \leq 24^{2}=576
$$

which again is impossible. If $a_{2}=5$, we obtain the maximal digital sum 23 when $a_{1}=a_{0}=9$. Otherwise $s(m) \leq 22$ and

$$
m=500+10 a_{1}+a_{0}<n=s(m)^{2} \leq 22^{2}=484
$$

Thus we can also rule out $a_{2}=5$. Therefore $a_{2} \leq 4$. This means, $m \leq 22^{2}$.

Now we can search which squares up to $22^{2}$ admit an $n$ such that $m=(s(n))^{2}$ and $n=(s(m))^{2}$. The first such square is $m=81=9^{2}$. But in this case $n=s(m)^{2}=81$. But now $m=n$ violating $m<n$. The next square is $m=169=13^{2}$. In this case $s(m)^{2}=16^{2}=256=n$ and $s(n)^{2}=13^{2}=169$. Thereafter, no square satisfies this. Thus we get the pair

$$
(m, n)=(169,256)
$$
