Sum of digits of a square number.

To be formal about this note that for $r$ large enough and $s$ a single decimal digit $$ (10^r-s)^2 = 10^{2r}-2s \cdot 10^r+r^2 = 9\cdot(10^{2r-1}+10^{2r-2}+\dots 10^{r+3})+(100-2s)\cdot10^r+s^2$$

So we begin with a string of $9$s which is $r-3$ long followed by two digits which are fixed (and may be zero or $9$), then a string of zeros followed by either one or two digits of $s^2$. Every time you increase $r$ by one, the digit sum increases by the addition of a single leading $9$.

Take $s=1$ to see what happens

$9^2=81$

$99^2=9801$

$999^2=998001$

This deals with $9,18, 27\dots$

With $s=2$

$8^2=64$

$98^2=9604$

$998^2=996004$

Which deals with $10,19,28\dots$

With $s=3$

$7^2=49$

$97^2=9409$

$997^2=994009$

Which deals with $13,22,31\dots$

$s=4$ deals with multiples of $9$ again.

$s=5$ gives

$5^2=25$

$95^2=9025$

$995^2=990025$

And this deals with $7,16,25\dots$

With the addition of a few early cases which these miss, you can show that you hit every positive element of every class of quadratic residue modulo $9$


Hint: ( Continuation of your method)

I find this method of observing patterns very interesting. So I will continue with same.

Write out first few good numbers like $$1,4,7,9,10,13,16,18,19,22,25,....$$

Now write down the differences between consecutive terms like $$3,3,2,1,3,3,2,1,3,3,...$$

Did you notice the pattern of differences. It repeats like $3,3,2,1$ and again and again.

So with simple algebra you must have your answer as $$223*4=892$$

Edit:

In general from $1$ to $9n$ ($n\in N$) there are $4n$ good numbers.