Numbers Equal to Sum of Squares of Digits

Theorem
There are exactly $2$ integers which are equal to the sum of the squares of their digits when expressed in base $10$:
 * $0 = 0^2$
 * $1 = 1^2$

Proof
We see the cases $0$ and $1$ above hold.

Suppose $N > 1$ is equal to the sum of the squares of their digits when expressed in base $10$.

Since $N^2 > N$, $N$ cannot be a $1$-digit integer.

Suppose $N$ is a $2$-digit integer.

Write $N = \sqbrk {a b} = 10 a + b$.

Then we have $a^2 + b^2 = 10 a + b$.

This can be reduced to $b \paren {b - 1} = a \paren {10 - a}$.

Since $b \paren {b - 1}$ is even, $a$ must be even as well.

The list of possible values of $a \paren {10 - a}$ are:


 * $2 \paren {10 - 2} = 8 \paren {10 - 8} = 16$
 * $4 \paren {10 - 4} = 6 \paren {10 - 6} = 24$

The list of possible values of $b \paren {b - 1}$ are:


 * $b \paren {b - 1} \le 4 \paren {4 - 1} = 12$ for $b \le 4$
 * $5 \paren {5 - 1} = 20$
 * $b \paren {b - 1} \ge 6 \paren {6 - 1} = 30$ for $b \ge 6$

We see that they do not coincide.

Thus $N$ cannot be a $2$-digit integer.

Suppose $100 \le N \le 199$.

Write $N = \sqbrk {1 a b} = 100 + 10 a + b$.

Then we have $1^2 + a^2 + b^2 = 100 + 10 a + b$.

This can be reduced to $b \paren {b - 1} = a \paren {10 - a} + 99$.

But we have $b \paren {b - 1} < 9 \times 8 = 72 < 99 \le a \paren {10 - a} + 99$.

So $N$ cannot be in this range.

Suppose $200 \le N \le 299$.

Then the sum of the squares of their digits cannot exceed $2^2 + 9^2 + 9^2 = 186 < 200$.

So $N$ cannot be in this range.

Suppose $300 \le N \le 999$.

Then the sum of the squares of their digits cannot exceed $9^2 + 9^2 + 9^2 = 243 < 300$.

So $N$ cannot be in this range.

Suppose $N$ is a $k$-digit integer with $k \ge 4$.

Then the sum of the squares of their digits cannot exceed $9^2 \times k$.

We have:

So $N$ cannot be greater than $1$.