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$. Determine all integers $n\geq 1$ such that $s(n)=n$.
Problem
Source:
Tags: number theory, Digits
15.09.2019 22:37
Let $n=\overline{a_1\cdots a_k}$ with $a_1\neq 0$ and $a_1,\dots,a_k\in\{0,1,\dots,9\}$. Notice that, $s(n)=\sum_{j=1}^k a_j^2 \leq 81k$. Moreover, $n\geqslant 10^{k-1}$. Thus, if $s(n)=n$ then we must have $10^{k-1}\leqslant 81k$. This fails clearly for $k\geqslant 4$. Thus, $n$ has at most three digits. Now, if $n$ has one digit, then $n=1$. If $n=\overline{ab}$ then we must have $10a+b=a^2+b^2$, thus $a\in\{2,4,6,8\}$. A quick inspection reveals we get no solutions (unless I made some computational error here). Thus, the only remaining case is $n$ having three digits. Set now $n=\overline{abc}$ with $a\neq 0$. Then, $100a+10b+c = a^2+b^2+c^2$. This yields $c^2-c=a(100-a)+b(10-b)\geqslant a(100-a)$. But now, this object is at least $99$ (easy to see). Thus, $c^2-c\geqslant 99$. On the other hand $c^2-c \leq 72$. This is a contradiction.
22.05.2021 00:28
If $n$ has $k$ digits, then $9^k\cdot n\geq 10^{n-1}$. It is easy to see that this only holds for $n\leq 3$. Thus, this problem is just casework bash. It is easy to see that for 1 digit, only 1 works. For the two digits, it reduces to $a_1^2+a_2^2=10a_1+a_2\implies (2a_1-10)^2+(2a_2-1)^2=101$. The only pair of squares that sum to $101$ is $10,1$ but this doesn't satisfy, $a,b\leq 9$. For three digits, we have that $a_1^2+a_2^2+a_3^2=100a_1+10a_2+a_3$. Notice that $3\cdot 9^2=243,$ so $a_1\leq 2$. But then if $a_1\leq 2,$ $2^2+9^2+9^2=165,$ so $a_1=1$. From here it is easy to just manually check that there are no more solution. Therefore, the only solution is $\boxed{1}$.
01.10.2021 20:08
Let $n=\overline{a_k\ldots a_0}$ be such that $s(n)=n$. First, notice that if $k\ge3$, then \[ s(n)=a_0^2+\ldots+a_k^2\le 81(k+1)<10^k\le 10^ka_k+\ldots+a_0=n, \]so we must have $k<3$. That is, $n$ has $1,2$, or $3$ digits. If $n$ has $1$ digit, then $a_0=a_0^2$, so $n=a_0=1$. If $n$ has $2$ digits, then $a_0^2+a_1^2=10a_1+a_0$, so \[a_0(a_0-1)=a_1(10-a_1).\]Since the LHS is even, $a_1$ is even. Simple casework shows no $a_1$ works. If $n$ has $3$ digits, then \[ a_0^2+a_1^2+a_2^2=100a_2+10a_1+a_0. \]Note that $a_0^2+a_1^2+a_2^2\le3\cdot81=243$, so we must have $a_2\in\{1,2\}$. These give \begin{align} a_0^2&=99+a_1(10-a_1)+a_0\\ a_0^2&=196+a_1(10-a_1)+a_0\\ \end{align}However, $a_0^2\le81$, which is less than the RHS of both (1) and (2). Thus, the only integer $n$ with $s(n)=n$ is $n=1$. $\blacksquare$
24.12.2021 11:47
$n=\overline{a_1\cdots a_k}$ $n\geqslant 10^{k-1}$ $n\leqslant 81k$ $k=1,2,3$
30.03.2022 17:20
Suppose that $s(n)=n$. Case 1: $n$ has at least $4$ digits Let $n$ have $d\ge4$ digits. We have: $$10^{d-1}\le n=s(n)\le d\cdot9^2=81d,$$a contradiction with $d\ge4$. Case 2: $n$ has $3$ digits Our first estimation is as before, $n=s(n)\le3\cdot9^2=243$. Then the hundreds digit of $n$ is at most $2$, so $n=s(n)\le2^2+2\cdot9^2=166$. Repeating again, $n=s(n)\le1^2+6^2+9^2=118$, and then $n-s(n)\le1^2+1^2+9^2=83$, contradiction. Case 3: $n$ has $2$ digits Let $n=\overline{ab}$. We have $10a+b=a^2+b^2$, and since $b^2$ and $b$ have the same parity by FLT, $a$ must be even. If $a=2$, $b^2-b-16=0$ which has no solutions. If $a=4$, $b^2-b-24=0$ which has no solutions. If $a=6$, $b^2-b-24=0$ which has no solutions. If $a=8$, $b^2-b-16=0$ which has no solutions. So this case is also impossible. Case 4: $n$ has $1$ digit Finally $n=n^2$, so $n=\boxed1$. After collecting all of the cases, this is the only solution.
21.09.2023 18:34
jasperE3 wrote: $n=s(n)\le1^2+6^2+9^2=118$, and then $n-s(n)\le1^2+1^2+9^2=83$, contradiction. Nope. What about $n=99$?
01.02.2025 11:39
for k>1: 10^k*a(k)>=2a(k)^2