Today, a thread full of cool math facts appeared on Reddit. As usual, someone mentioned the fact that 111111111 × 111111111 = 12345678987654321. In another reply, someone pointed out that this also works in other bases. For some reason, I decided that I needed to prove that it works in *all* bases.

To begin, I needed a general formula for values of the 111… terms. This was fairly straightforward: for a base , we want base- digits, all ones. To standardize the base, we multiply each digit by an increasing power of and sum. Since each digit is one, we get a nice geometric series which can easily be solved.

When we multiply this number by itself, we are squaring it, so we end up with .

The hard part was writing a general form for the number. To deal with this, I broke it down into two parts, as illustrated below.

Digit value | 1 | 2 | 2 | 1 | |||||

Place multiplier | |||||||||

I calculated the values of the most-significant digits starting at the left, and the values of the least-significant digits starting at a right. To make the math come out nicely, I actually included the center digit in both formulas. That’s okay, since we can subtract it off once to make up for the duplicate. Now we have a summation formula for the value of the square.

With a little thinking (or the help of a computer algebra system), we can get a neat closed form.

We can see that this is quite similar to the expression we got for the square above; the only difference is that the denominator has changed to . Fortunately, this negation goes away when squaring, so we can trivially prove that the two expressions are equal.

And there we have it: proof that this curiosity is true in any base of at least two.