TITLE: Digit-Sum of a Number.
QUESTION [9 upvotes]: I got a question recently, and I am unable to solve it.

Find all natural numbers $N$, With sum of digits $S(N)$, where $N=2\{S(N)\}^2$

I know that $9|N-S(N)$, and since N is twice a square, it must end in $0,2,8$. But I do not know where to go from here. Can anyone help?
The Official Solution from the Organization
We use the fact that $9|n−S(n)$ for every natural number $n$. Hence $S(n)(2S(n)−1)$ is divisible by $9$. Since $S(n)$ and $2S(n)−1$ are relatively prime, it follows that $9$ divides either $S(n)$ or $2S(n)−1$, but not both. We also observe that the number of digits of $n$ cannot exceed $4$. If $n$ has $k$ digits, then $n≥10k−1$ and $$2S(n)^2≤2\cdot(9k)^2=162k^2$$ If $k≥6$, we see that $$2S(n)^2≤162k^2<5^4k^2<10^{k−1}≤n$$ If $k = 5$, we have $$2S(n)^2≤162\cdot25=4150<10^4≤n$$
Therefore $n ≤ 4$ and $S(n) ≤ 36$. If $9|S(n)$, then $S(n) = 9,18,27,36$. We see that $2S(n)^2$ is respectively equal to $162, 648, 1458, 2592$. Only $162$ and $648$ satisfy $n = 2S(n)^2$. If $9|(2S(n)−1)$, then $2S(n) = 9k+1$. Only $k = 1,3,5,7$ give integer values for $S(n)$. In these cases $2S(n)^2 = 50,392,1058,2048$. Here again $50$ and $392$ give $n = 2S(n)^2$. Thus the only natural numbers wth the property $n = 2S(n)^2$ are $50,162,392,648$.

REPLY [5 votes]: @Pjotr5 identified the solution but asked for a sharper bound.  Here all four-digit candidates are eliminated through a descent process leaving only the numbers in his list up to and including $648$.
First off, five-digit numbers give a digit sum no greater than $45$ whose square, doubled, is less than five digits ($2×45^2=4050$).  Contradiction.  Ditto for more than five digits.
Four-digit numbers give digit sums no more than $36$ whose square, doubled, is $2592$.  So a four-digit solution is at most $2592$.  But wait, there's more (or less, if you will).  If the first digit of the proposed four-digit solution is no more than $2$ the sum of digits is now no more than $29$ giving a bound of $2×29^2=1682$, and then if the first digit has to be $1$ the sum of digits is at most $28$ giving $N\le 1568$.
The four-digit bound can still be lowered more.  The bound of $1568$ derived above means the first two digits are no more than $15$ and can't sum to more than $6$.  Then the sum of the four digits is no longer bounded only by $28$ but now bounded by $24$.  Twice the square of that is $1152$ so now $N \le 1152$.
You know the drill by now.  If $N$ has four digits and is less than or equal to $1152$ then the sum of digits is no more than $20$.  Twice the square of that is only $800$, less than four digits, so no four-digit candidates are left!