Let $S(n)$ be the sum of the digits of a number $n$. Solve $n+S(n)+S(S(n))=1993$

My first step is to just to try to understand the problem by considering specific values of $n$. In the simplest case, $n=1$, and then $S(n)=1$ and $S(S(n))=1$, and the sum of these values is 3, which does not equal 1993 (as expected). Similarly for all single-digit numbers, we would have $2+2+2,\enspace3+3+3,\ldots,\enspace9+9+9$.

Then it occurred to me that $n$ cannot equal or exceed $1993$, because then $n$ by itself would equal or exceed the full sum, and the sum of the digits of $n$ cannot be zero or negative. On the other hand it seems that $n$ would need to be relatively close to $1993$ because $S(n)$ and $S(S(n))$ are relatively small in comparison to $n$. For example when $n=999\enspace S(n)=27$ and $S(S(n))=9$

I've been playing around with numbers from $1949$ and up, but can't quite get a sum of $1993$. I'm sure there's a theory behind this, but it's beyond me right now. Any thoughts?

There are no solutions. Hint: for all integers $n$ we have $n \equiv S(n) \mod 3$.

• Ah, so it's kind of a "trick" question. Thank you. – yroc Mar 21 '15 at 22:48

The most straightforward is timon92's solution, but you can solve this by limiting the possible values of $n$ and then checking them all:

Clearly $S(n)\le 1+9+8+9=27$ and $S(S(n))\le 1+9=10$ and so $$1993=n+S(n)+S(S(n))\le n+27+10=n+37\iff n\ge 1956\tag{1}$$

Hence $S(n)\ge 1+9+6+0=16$ and $S(S(n))\ge 2$ and so $$1993=n+S(n)+S(S(n))\ge n+16+2=n+18\iff n\le 1975\tag{2}$$

$$(1)(2)\implies (1956\le n\le 1975)$$

What is left is checking these values of $n$.

• Great, I like the bracket approach if the solver didn't happen to notice timon's neat mathematical improvement. You can actually raise the lower limit again but after that you're stuck with checking. Sooner or later, going through it practically, the solver might notice that they're always changing the result by a multiple of 3. – Joffan Mar 21 '15 at 23:09
• @Joffan not sure what you mean - I mentioned his solution in the first sentence. This is just an alternate solution that might help in a different problem, like if $1993$ were replaced with a number divisible by $3$. – user26486 Mar 21 '15 at 23:11
• Understood, I was not suggesting you change anything, just agreeing – Joffan Mar 21 '15 at 23:11