# Square of digit reversal equals digit reversal of square?

A recent question brought up the phenomenon that for some nonnegative integers $n$, $$R(n^2) = R(n)^2,$$ where $R(n)$ means the digit reversal of $n$ (sometimes written $\overline{n}$). Some care is needed with regards to how to handle leading or tailing zeroes. However you decide the issue, one can see that it does not significantly affect the condition.

The comments and answers on that question explained that this happened whenever no carries are involved in the standard multiplication algorithm for computing $n^2$. (For example, one can directly see this happens when $n$ is $13$, $113$, or $212$.) Michael Lugo commented that the full sequence of numbers $n$ satisfying the condition is in the Online Encyclopedia of Integer Sequences (OEIS) as sequence A061909, where they are called "skinny numbers".

Is the fact that no carries happen necessary or merely sufficient? This question is implicitly posed at the end of the accepted answer and discussed in its comments.

Carefully reading the helpful comments in the OEIS tells us that it is both necessary and sufficient! Indeed, it appears that historically there were two separate entries which ended up merged because of this equivalence. (No proof is given or cited.)

But why? To summarize: why does $R(n^2) = R(n)^2$ imply that no carries happen in the multiplication $n^2$?

Assume that there's no carry in the left-most place when computing $n^2$. In that case, $R(n)^2 \ge R(n^2)$, with equality if and only if the multiplication in $n^2$ is carry-free, and this proves the claim.

To see this, consider that if we replace ordinary multiplication by polynomial multiplication (treating a number such as $123$ as the polynomial $x^2+2x+3$) then squaring and reversing commute. If there's carrying to be done, then some of our coefficients are bigger than $9$: for example, if we turn $14$ into $x+4$ and square it, we get $x^2 + 8x + 16$.

Whether we turn this into $R(14)^2 = 1681$ or $R(14^2) = 691$ depends on which operation we do first to this polynomial: reversing, or doing the carrying step. Equivalently, we can decide to do the reversing first, but carry either backwards or forwards. That is, reverse the polynomial to get $16x^2 + 8x + 1$ and either turn $10x^2$ into $x^3$ (to get $x^3 + 6x^2 + 8x+1$) or turn $10x^2$ into $x$ (to get $6x^2 + 9x+1$). Either way, once the polynomial has no coefficients greater than $9$, we can get back a number by substituting $x=10$.

But it's easy to see that replacing $10x^2$ by $x^3$ (or more generally, $10x^k$ by $x^{k+1}$) doesn't change the value when $x=10$, whereas replacing $10x^k$ by $x^{k-1}$ decreases it when $x=10$. So every carry step makes $R(n^2)$ (which carries backwards) smaller than $R(n)^2$ (which carries forwards).

The only case where this doesn't work is when the carry is in the leftmost place. In that case, you don't turn a $10x^0$ into $x^{-1}$ when carrying backwards: you do that, but multiply by $x=10$, and the inequality no longer holds. But you say you have an argument (which I can't find) which rules out that case as well.

• Here's the last-most digit argument: math.stackexchange.com/a/1187046/19328 Mar 14, 2017 at 4:59
• Oh, I see; I didn't make the connection between "even number of digits" and "carry in the leftmost place", but of course a degree $k$ polynomial squares to a degree $2k$ polynomial, which is a $(2k+1)$-digit number, which turns into a $(2k+2)$-digit number if and only if we carry. Mar 14, 2017 at 5:06
• Nice argument!! Mar 14, 2017 at 9:24
• No part of your argument uses that we're usually in base $10$ (decimal), but the left-most digit argument does. It turns out that this is essential, because in other bases the statement is false! For example, in base $2$, there is the easy example $3 = 11_2$. In base $3$, there are $2$, $20 = 202_3$, and $56 = 2002_3$. In base $7$, there's $4$, $32 = 44_7$, and $40 = 55_7$. I wonder which bases are possible ... Mar 14, 2017 at 10:08