# If $n$ is a square, can $n$ consist of only odd digits?

The question is: If $n$ is a square, can $n$ consist of only odd digits?

I have a feeling that the answer is no, with the only exceptions being $n=1,9$. I am not sure how to go about proving this though. Any help or hints would be appreciated.

• The statement to prove is unclear...? Are you trying to find some perfect square such that the digits in its base-10 representation is not all odd? – Megadeth Nov 11 '15 at 10:10
• If $n$ is a square, then $n$ does not consist of all odd digits. – JVV Nov 11 '15 at 10:11
• If that is the case, consider $n : =4$. – Megadeth Nov 11 '15 at 10:12
• @JVV: Do you mean "If $n\ge 16$ is a square, then $n$ has at least one even digit"? – mathlove Nov 11 '15 at 10:14
• @mathlove: Yes, this would be a better statement of the question. – JVV Nov 11 '15 at 10:15

Assume $n=m^2$ and all digits of $n$ are odd. Then certainly $m$ is odd (as otherwise $n$ is even and ends in an even digit). Note that $(m+50)^2=m^2+100m+2500\equiv m^2\pmod{100}$ so that it suffices to show that for all odd $m=1,3,5,\ldots ,49$ the tens digit is even. Actually, already for $(m+10)^2=m^2+20m+100\equiv m^2+20m\pmod{100}$ the tens digit parity is the same as for $m^2$, so it really suffices to check $m=1,3,5,7,9$ where $n=01,09,25,49,81$ has even tens.

• Does this mean that, either $m$ ends in $4$ or $6$, or $m^2$ has an even tens digit, but not both or neither? – Akiva Weinberger Nov 17 '15 at 15:49
• @AkivaWeinberger To reiterate the proof in a different perspective: The sequence of $m^2\bmod 20$ runs like this: $0,1,4,9,16,5,16,9,4,1$ and then starts over again. Thus the only cases with odd tens digit are indeed those with $m\equiv 4$ or $m\equiv 6\pmod{10}$. – Hagen von Eitzen Nov 17 '15 at 23:08

Modulo $10$, we have $n^2=(10k\pm d)^2=100k^2\pm20kd+d^2$, where $d\in\{0,1,2,3,4,5\}.$ Notice

that the tens' digit is always even, except when we have a carry, i.e., when $d^2>9\iff d=4$

and/or $d=5.$ The former case can be discarded, since it yields and even units' digit. The same

goes for the latter, since $25$ yields an even carry.

The odd quadratic residues of 20 are 1, 5 and 9. Any square congruent to one of these has an even tens digit.