Digit-Sum of a Number.

We want to find an upper bound for $N$ for which it is possible that $N = 2 S(N)^2$. The upper bound that I use in the following is very rough, but I think still just good enough to be able to do the subsequent calculations by hand with a little persistence. Look to the answer of @OscarLanzi for a much cleverer upper bound.

An upper bound for $S(N)$ is $$S(N) \leq 9\cdot \left(\log_{10}(N)+1\right).$$ We can use this upper bound to see that $$ 2 S(N)^2 - N \leq 2 \cdot \left(9\cdot \left(\log_{10}(N)+1\right) \right)^2 - N.$$ For $N = 10^4$ we see that the right hand side of this inequality is $4050 - 10^4 = -5950 < 0$ and by calculating derivatives we can see fairly easily that this expression will only decrease for $N > 10^4$. This means that if we want to find $N$ such that $N = 2 S(N)^2$ we only have to check numbers up to $10^4$, this is a very rough upper bound.


Note that indeed that $N \equiv S(N) \pmod{9}$ so $N$ must satisfy $$N - 2 N^2 \equiv 0 \pmod{9},$$ we deduce that $N \equiv 0 \pmod{9}$ or $N \equiv 5 \pmod{9}$. We see that $N$ must be twice a square and less than $10^4$, so $2S(N)^2 \leq 10^4$, which means that $S(N) \leq \sqrt{\frac{1}{2}\cdot{10^4}} \cong 70.7$. So $S(N)$ must be a number less than or equal to $70$ that is either $0$ or $5$ modulo $9$. There are only fifteen such positive numbers, the list is $$\left\{5,9,14,18,23,27,32,36,41,45,50,54,59,63,68\right\}.$$ These can all be checked separately, the list of these elements squared twice is $$\left\{\mathbf{50},\mathbf{162},\mathbf{392},\mathbf{648},1058,1458,2048,2592,3362,4050,5000,5832,6962,7938,9248\right\}.$$ Sort of surprisingly the first four all fit. These are the only ones, so the final answer is $$N \in \left\{50, 162, 392, 648\right\}.$$ The amount of checking to be done can be reduced by getting a better upper bound.


@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!

Tags:

Contest Math