To summarize the discussion in the comments:
Let's denote the iterated digit sum by $S(n)$. It is well known, and easy to demonstrate, that $n\equiv S(n)\pmod 9$. Indeed, $S(n)$ is essentially equal to the remainder you get on dividing $n$ by $9$, with the proviso that if the remainder is $0$, $S(n)=9$.
Now, consider the sequence $\mathscr S=\{S(n^2)\}$. Since $(n+9)^2\equiv n^2\pmod 9$ we see that $\mathscr S$ is periodic with period $9$. A priori there might be a period smaller than $9$ but in this case there is not.
The same argument would apply to any power, not just squares. For instance the sequence of the digit sum of cubes is $\{1,8,9,1,8,9,\cdots\}$ which has period $3$ (note that $3$ divides $9$ so $9$ is still a period, just not the least one). Or you could take fifth powers to get the periodic sequence $$\{\overline {1,5,9,7,2,9,4,8,9}\}$$
and so on.
1, 4, 9, 7, 7, 9, 4, 1, 9as sequential numbers. So given "1 to N", the result keeps repeating1, 4, 9, 7, 7, 9, 4, 1, 9? (This is actually asked for my son who found this phenomenon :D) – Devs love ZenUML Oct 01 '22 at 12:21