Recently, I have been spending quite a bit of time with nothing more than a pencil and a stack of graph paper, and simply playing with numbers.
I noticed that if you square a string of n 1’s, you get a number whose digits count up to n, then count back up. (Which is easily understandable.)
If you sum these digits, you end up with $n^2$. (I’m nearly 100% sure someone has discovered this before me, it’s pretty simple)
I do not fully understand why this occurs, could someone help explain?
Here are a few examples: $$1^2=1; 1=1; 1=1^2$$ $$11^2=121; 1+2+1=4; 4=2^2$$ $$111^2=12321; 1+2+3+2+1=9; 9=3^2$$ $$...$$ $$11111111^2=123456787654321; 1+2+3+4+5+6+7+8+7+6+5+4+3+2+1=64; 64=8^2;$$ $$...$$
Let us more generally consider what happens when you compute $(1+x+x^2+\dots+x^{n-1})^2$ (in your case, $x=10$). We will get an $x^k$ term for each pair $(i,j)$ of integers in $[0,n-1]$ such that $i+j=k$. If $0\leq k\leq n-1$, then there are $k+1$ such pairs: $i$ can be anything from $0$ to $k$, and then $j$ must be $k-i$. If $n-1\leq k\leq 2n-2$, then taking $k'=2n-2-k$, pairs $(i,j)$ which sum to $k$ are in bijection with pairs $(i',j')$ which sum to $k'$ by taking $i'=n-1-i$ and $j'=n-1-j$. So the coefficient of $x^k$ is the same as the coefficient of $x^{k'}$, which is $k'+1=2n-1-k$. Concretely, this means we have $$(1+x+x^2+\dots+x^{n-1})^2=1+2x+3x^2+\dots+(n-1)x^{n-2}+nx^{n-1}+(n-1)x^n+\dots+x^{2n-2}.$$ For $x=10$, this gives exactly the decimal expansions you have seen (at least, as long as $n<10$ so the coefficients do not spill over into other digits). Other integer values $x>1$ correspond to doing the same process in different bases.
Now to sum the digits of your squares, we can just take $x=1$ instead of $x=10$, so that each power of $10$ becomes $1$ and we are just adding their coefficients (i.e., the digits). We thus find that the sum of the digits is $(1+1+1^2+\dots+1^{n-1})^2=n^2$.