Why does this pattern work: $1 \cdot{1} = 1, 11 \cdot{11} = 121, 111 \cdot{111} = 12321\ldots$ I have recently learned about pattern that goes like this:
$$\begin{align}
1^2 &= 1\\
11^2 &= 121\\
111^2 &= 12,321\\
1,111^2 &= 1,234,321\\
11,111^2 &= 123,454,321.
\end{align}$$
It is a very cool pattern, but after a bit it stops:
$$1,111,111,111^2 = 1,234,567,900,987,654,321$$
My main question:

Why does this pattern work?

A side question that's less important:

Is there an algebraic equation to describe this pattern?


Other answers have already provided some intuition behind the pattern. Here is some terminology:

*

*The numbers being squared, e.g. $111111$, are called repunits.


*The resulting products are called Demlo numbers: $\,1, 121, 12321, 1234321,\, \dots$

Repunits can be written as sums of powers of $10$, and from that perspective, base-$10$ repunits are finite geometric series. For example:
\begin{align}
111111 &= 1 + 10 + 100 + 1000 + 10000 + 100000\\
111111&=1 + 10 + 10^2 + 10^3 + 10^4 + 10^5\\\\
111111&=\displaystyle\frac{10^6-1}{10-1}\\\\
111111&=\displaystyle\frac{10^6-1}{9}
\end{align}
The last two lines above use the formula for the sum of a finite geometric series.
Squaring gives:
\begin{align}
111111^2 &= \left(\displaystyle\frac{10^6-1}{9}\right)^2\\
111111^2 &= \displaystyle\frac{10^{12} - 2\cdot 10^6 +1}{81}
\end{align}
In general:
$$\left(\,\underbrace{\,1111\,\dots\,1111\,}_{ n \text{ ones} } \,\right)^2 \, = \,\, \boxed{\displaystyle\frac{10^{2n} - 2\cdot 10^n +1}{81}\,}$$

Demlo numbers are sequence A002477 in the OEIS.
