Maths Olympiad Prep

Library / Iberoamerican Olympiad /2 of 11

Iberoamerican Olympiad

Number theory Difficulty 6.2 National Olympiad Find the answer

For each positive integer nn, let s(n)s(n) be the sum of the squares of the digits of nn. For example, s(15)=12+52=26s(15)=1^2+5^2=26. Determine all integers n≥1n\geq 1 such that s(n)=ns(n)=n.

A number or a short expression. Fractions can be typed as 3/2, and spacing doesn't matter.

Solution

Given the problem, we want to determine all integers n≥1 n \geq 1 such that the sum of the squares of the digits of n n , denoted as s(n) s(n) , is equal to n n .

To begin, let's express n n in terms of its digits. Suppose n n is a k k -digit number given by:
n=dk−1⋅10k−1+dk−2⋅10k−2+⋯+d1⋅101+d0⋅100 n = d_{k-1} \cdot 10^{k-1} + d_{k-2} \cdot 10^{k-2} + \cdots + d_1 \cdot 10^1 + d_0 \cdot 10^0
where di d_i represents the i i -th digit of n n and 0≤di≤9 0 \leq d_i \leq 9 for 0≤i≤k−1 0 \leq i \leq k-1 , with dk−1≠0 d_{k-1} \neq 0 because dk−1 d_{k-1} is the leading digit.

The function s(n) s(n) is defined as:
s(n)=dk−12+dk−22+⋯+d12+d02. s(n) = d_{k-1}^2 + d_{k-2}^2 + \cdots + d_1^2 + d_0^2.

Given s(n)=n s(n) = n , we want:
dk−12+dk−22+⋯+d12+d02=dk−1⋅10k−1+dk−2⋅10k−2+⋯+d1⋅101+d0. d_{k-1}^2 + d_{k-2}^2 + \cdots + d_1^2 + d_0^2 = d_{k-1} \cdot 10^{k-1} + d_{k-2} \cdot 10^{k-2} + \cdots + d_1 \cdot 10^1 + d_0.

For k=1 k = 1 , n=d0 n = d_0 , we reach a straightforward solution:
s(n)=d02=n=d0  ⟹  d02=d0. s(n) = d_0^2 = n = d_0 \implies d_0^2 = d_0.
Thus, d0=0 d_0 = 0 or d0=1 d_0 = 1 . Since n≥1 n \geq 1 , we have d0=1 d_0 = 1 . This gives n=1 n = 1 .

For k≥2 k \geq 2 , we explore the possibility of higher k k . Notice that for a two-digit number n n with digits d1,d0 d_1, d_0 :
s(n)=d12+d02andn=10d1+d0. s(n) = d_1^2 + d_0^2 \quad \text{and} \quad n = 10d_1 + d_0.
Thus, d12+d02=10d1+d0 d_1^2 + d_0^2 = 10d_1 + d_0 .

To analyze further, consider the rough inequality result for the maximum digit value:
d12+d02≤81+81=162. d_1^2 + d_0^2 \leq 81 + 81 = 162.
This suggests n=10d1+d0≤162 n = 10d_1 + d_0 \leq 162 . However, testing feasible digit options within this limit shows no solutions beyond the trivial single-digit case n=1 n = 1 .

The analysis implies that the only integer n≥1 n \geq 1 satisfying s(n)=n s(n) = n is indeed:
1 \boxed{1}
This wraps up the exploration, confirming that 1 is, in fact, the unique solution.

Want a route through all this instead of an archive? The track puts 2,604 problems in a working order, from Junior Challenge level to the IMO shortlist.

Source: Omni-MATH, licensed Apache-2.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.