# Square sequence puzzle two

Find what comes next in the following sequence: 0,1,4,9,7,7,9,13,10,9,1,? Bonus: What is the rule?

The $$n$$th term of the sequence is
the sum of the digits of $$n^2$$ (in base $$10$$) so the next term is $$1+2+1=4$$.
if $$k$$ is not divisible by $$9$$ and $$k-1$$ is not divisible by $$3$$, i.e. $$k$$ modulo $$9$$ is in $$\{2,3,5,6,8\}$$, then $$k$$ cannot be in the sequence because the sum of digits of $$n^2$$ is the same modulo $$9$$ as $$n^2$$ itself, which must be $$0,1,4$$ or $$7$$. If $$k$$ is divisible by $$9$$, then note that $$33...3$$ with $$\frac{k}{9}$$ $$3$$'s squared is $$11...1088...89$$ with $$\frac{k}{9}-1$$ $$1$$'s and $$8$$'s, so its sum of digits is $$k$$. Otherwise, note that $$33...35$$ with $$\frac{k-7}{3}$$ $$3$$'s squared is $$11...122...25$$ with $$\frac{k-7}{3}$$ $$1$$'s and $$\frac{k-4}{3}$$ $$2$$'s; this has sum of digits $$k$$. Therefore, since $$k=1$$ and $$k=4$$ obviously appear in the sequence, the numbers that never appear in the sequence are the positive integers that are $$2,3,5,6$$ or $$8$$ modulo $$9$$.