Why are the last two digits of a perfect square never both odd?

7.7k Views Asked by At

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?

8

There are 8 best solutions below

3
On 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.

2
On

As a hint, consider what determines the last two digits of a multiplication. Do you remember doing multiplication by hand? If you have square a ten digit number, do all the digits matter when considering just the last two digits of the answer? You will realize that you can put a bound on the number of squares you need to check before you can prove the assertion you are making for all n

0
On

In the spirit of experimentation, the last two digits of the squares of numbers obtained by adding the column header to the row header:

$$\begin {array}{c|ccc} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline 0 & 00 & 01 & 04 & 09 & 16 & 25 & 36 & 49 & 64 & 81\\ 10 & 00 & 21 & 44 & 69 & 96 & 25 & 56 & 89 & 24 & 61\\ 20 & 00 & 41 & 84 & 29 & 76 & 25 & 76 & 29 & 84 & 41\\ 30 & 00 & 61 & 24 & 89 & 56 & 25 & 96 & 69 & 44 & 21\\ 40 & 00 & 81 & 64 & 49 & 36 & 25 & 16 & 09 & 04 & 01\\ 50 & 00 & 01 & 04 & 09 & 16 & 25 & 36 & 49 & 64 & 81\\ 60 & 00 & 21 & 44 & 69 & 96 & 25 & 56 & 89 & 24 & 61\\ 70 & 00 & 41 & 84 & 29 & 76 & 25 & 76 & 29 & 84 & 41\\ 80 & 00 & 61 & 24 & 89 & 56 & 25 & 96 & 69 & 44 & 21\\ 90 & 00 & 81 & 64 & 49 & 36 & 25 & 16 & 09 & 04 & 01\\ 100 & 00 & 01 & 04 & 09 & 16 & 25 & 36 & 49 & 64 & 81\\ 110 & 00 & 21 & 44 & 69 & 96 & 25 & 56 & 89 & 24 & 61\\ 120 & 00 & 41 & 84 & 29 & 76 & 25 & 76 & 29 & 84 & 41\\ \end{array}$$

The patterns are clear, after which the search for a reason for such patterns is well given by the answer of @RossMillikan - you can see that the parity of both final digits of the square is entirely dependent on the final digit of the number that you square.

0
On

Others have commented on the trial method. Just to note that $3^2$ in base $8$ is $11_8$ which has two odd digits. This is an example to show that the observation here is not a trivial one.

But we can also note that $(2m+1)^2=8\cdot \frac {m(m+1)}2+1=8n+1$ so an odd square leaves remainder $1$ when divided by $8$.

The final odd digits of squares can be $1,5,9$ so odd squares are $10p+4r+1$ with $r=0,1,2$. $10p+4r$ must be divisible by $8$ and hence by $4$, so $p$ must be even.

0
On

This is just another version of Ross Millikan's answer.

Let $N \equiv 10x+n \pmod{100}$ where n is an odd digit.

\begin{align} (10x + 1)^2 \equiv 10(2x+0)+1 \pmod{100} \\ (10x + 3)^2 \equiv 10(6x+0)+9 \pmod{100} \\ (10x + 5)^2 \equiv 10(0x+2)+5 \pmod{100} \\ (10x + 7)^2 \equiv 10(4x+4)+9 \pmod{100} \\ (10x + 9)^2 \equiv 10(8x+8)+1 \pmod{100} \\ \end{align}

2
On

A simple explanation.

  1. Squaring means multiplication, multiplication means repeatative additions.

  2. Now if you add even no.s for odd no. of times or odd no.s for even no. of times you will always get an even no.

Hence, square of all the even no.s are even, means the last digit is always even.

  1. If you add odd no.s for odd no. of times you will always get an odd no.

Coming to the squares of odd no.s whose results are >= 2 digits. Starting from 5^2 = 25, break it as 5+5+5+5+5, we have a group with even no. of 5 and one extra 5. According to my point no. 2 the even group will always give you a even no. i.e. 20, means the last digit is always even. Addition of another 5 with 20 makes it 25, 2 is even.

Taking 7^2, 7+7+7+7+7+7+7, group of six 7's = 42 plus another 7 = 49.

Now consider 9^2, 9+9+9+9+9+9+9+9+9, group of eight 9's = 72 plus another 9 = 81, (72+9 gets a carry of 1 making the 2nd last digit even)

35^2 = group of twenty four 34's (1190) plus 35 = 1225, carry comes.

In short just check the last digit of no. that you can think of in the no. co-ordinate (Real and Imaginary) it will always be b/w 0-9 so the basic principle (point 2 and 3) will never change. Either the last digit will be an even or the 2nd last digit will become even with a carry. So the 1 digit sq can come odd, 1 and 9, as there is no carry. I have kept it as an exception in point 3.

BTW many, including the author may not like my lengthy explanation as mine is not a mathematical one, full of tough formulae. Sorry for that. I'm not from mathematical background and never like maths.

0
On

Let b be last digit of odd perfect square a,then b can be 1,9 or 5. For b=1,9; $a^2-b$ is divisible by 4, $(a^2-b)/10$ is even. For b=5 ;a always ends in 25.

0
On

Recall the following two facts,

Proposition 1: If $s$ is any integer then $s^2 \equiv (s+50)^2 \pmod{100}$.

Proposition 2: The following four modulo statements are true,

$\; 1^2 \equiv 9^2 \equiv 11^2 \equiv 19^2 \equiv 21^2 \equiv 29^2 \equiv 31^2 \equiv 39^2 \equiv 41^2 \equiv 49^2 \pmod{20}$

$\; 2^2 \equiv 8^2 \equiv 12^2 \equiv 18^2 \equiv 22^2 \equiv 28^2 \equiv 32^2 \equiv 38^2 \equiv 42^2 \equiv 48^2 \pmod{20}$

$\; 3^2 \equiv 7^2 \equiv 13^2 \equiv 17^2 \equiv 23^2 \equiv 27^2 \equiv 33^2 \equiv 37^2 \equiv 43^2 \equiv 47^2 \pmod{20}$

$\; 4^2 \equiv 6^2 \equiv 14^2 \equiv 16^2 \equiv 24^2 \equiv 26^2 \equiv 34^2 \equiv 36^2 \equiv 44^2 \equiv 46^2 \pmod{20}$

$\text{*****}$

It is immediate that if $n \equiv 0 \pmod5$ then $n^2$ can't end in two odd digits.

Also, if the last two digits $n^2$ are not both odd and $m \equiv n \pmod{20}$ then the last two digits of $m^2$ can't both be odd.

Putting all the above together we proceed with the calculations,

$\quad 1^2 \equiv 1 \pmod{20}$
$\quad 2^2 \equiv 4 \pmod{20}$
$\quad 3^2 \equiv 9 \pmod{20}$
$\quad 4^2 \equiv 16 \pmod{20}$

and we see that for every integer $n$ the last two digits of $n^2$ can't both be odd.


We can also derive the result given by Raffaele in his comment below the OP's question.

If the units digit of an integer $n$ is $0$ then the last two digits of $n^2$ is equal to $00$.

If the units digit of an integer $n$ is $5$ then the last two digits of $n^2$ is equal to $25$.

The remaining possibilities can be found by looking at the four sequences generated (extrapolated) from proposition 2:

$\quad 01, 21, 41, 61, 81$
$\quad 04, 24, 44, 64, 84$
$\quad 09, 29, 49, 69, 89$
$\quad 16, 36, 56, 76, 96$

So there are a total of $22$ different endings.

Exercise:
Show that each of these $22$ endings occurs as the last two digits of the square of some integer.