Number Theory – Why Last Two Digits of a Perfect Square Are Never Both Odd

decimal-expansionelementary-number-theorysquare-numbers

Earlier today, I took a test with a question related to the last two digits of perfect squares.

I wrote out all of these digits pairs up to $20^2$.

I noticed an interesting property, and when I got home I wrote a script to test it. Sure enough, my program failed before it was able to find a square where the last two digits are both odd.

Why is this?

Is this always true, or is the rule broken at incredibly large values?

Best Answer

Taking the last two digits of a number is equivalent to taking the number $\bmod 100$. You can write a large number as $100a+10b+c$ where $b$ and $c$ are the last two digits and $a$ is everything else. Then $(100a+10b+c)^2=10000a^2+2000ab+200ac+100b^2+20bc+c^2$. The first four terms all have a factor $100$ and cannot contribute to the last two digits of the square. The term $20bc$ can only contribute an even number to the tens place, so cannot change the result. To have the last digit of the square odd we must have $c$ odd. We then only have to look at the squares of the odd digits to see if we can find one that squares to two odd digits. If we check the five of them, none do and we are done.