Three digit integers with $S(S(n))=2$

44 Views Asked by At

For any natural number, let $S(n)$ denote the sum of the digits of $n$. Find the number of $3$ digit numbers for which $S(S(n)) = 2$.

Attempt: It is easy to see that the numbers which satisfy $S(S(n)) = 2 $ also satisfy that $S(n)$ is one of $2,11,20$.

But then $S(n) \equiv 2 \pmod 3 $ and hence $n \equiv 2 \pmod 3 $. Thus we have that all $3$ digit numbers of the form $3k+2 $ for natural $k$ satisfy our condition. Clearly this is an arithmetic progression with $101$ as first term and common difference $3$. Hence the total number of solutions is the greatest integer that satisfies $ 101+3(n-1) < 1000 $ and thus $ n = 300 $.

However, this count is incorrect, as we will also include numbers like $224$ and $332$ that don't satisfy the condition given in the question.

I do not know how to solve this problem.

1

There are 1 best solutions below

2
On BEST ANSWER

There is a very quick and easy solution. Note that for a three-digit number $n$, $S(n)\leq27$, and that the sum of the digits of any integer not greater than $27$ is at most $10$. Since $S(n)\equiv n\pmod{9}$ by what is essentially the $9$ divisibility rule, $S(S(n))=2$ must hold for precisely the three digit numbers congruent to $2\pmod{9}$, or the numbers $$101,110,119,\ldots,992.$$ It's very easy to see that this list has exactly $\boxed{100}$ elements.


We can also do a more brute-force approach. Again, for $n$ a three-digit number, $S(n)\leq27$. The only integers less than $27$ with digit sum $2$ are $2$, $11$, and $20$. Therefore, if $S(S(n))=2$, we must have $$S(n)\in\{2,11,20\},$$ as you had already established. This gives three cases:

  • If $S(n)=2$, it's clear that $n\in\{101,110,200\}$, giving $3$ possibilities.
  • If $S(n)=11$, we write $n=100a+10b+c$, with $a\neq0$, and $0\leq a,b,c\leq 9$. We want $a+b+c=11$. By Stars and Bars, there are $\binom{13}{2}$ possibilities for $a$, $b$, $c$, excluding $9$ cases in which a digit exceeds $9$, and a further $8$ cases where $a=0$. In total, this case gives $61$ possibilities.
  • If $S(n)=20$, we write $n=100(9-a)+10(9-b)+(9-c)$, with $a\neq9$, and $0\leq a,b,c\leq9$. We want $a+b+c=7$. This time around, Stars and Bars works directly, giving $\binom{9}{2}$ or $36$ further possibilities.

Adding all up, we once more get a final answer of $3+61+36=\boxed{100}$ numbers.