[Math] How to prove “Unit digit of a square number”

elementary-number-theorymodular arithmeticnumber theoryquadratic-residues

How can I prove that the unit digit of a perfect square is always $0,1,4,9,5,6$ and never $2,3,7,8$?

It's pretty intuitive but I am having difficulties proving this statement.
I had used trial and error to get to that statement.

Note(The original problem was: If the length and width of a rectangle are consecutive positive integers and the area has $6$ in its unit digit.Is it possible to say that one of the length or width is a perfect square number ?)

Best Answer

Any integer can be written as $10n+r$ where $n,r$ are integers with $0\leq r<10$. Then the unit digit of the square $$(10n+r)^2=100n+20rn+r^2=10(\underbrace{10n+2rn}_{\text{integer}})+r^2$$ is equal to the unit digit of $r^2$. So it suffices to consider the unit digit of $r^2$ when $r\in \{0,1,2,3,4,5,6,7,8,9\}$.

Thus we may conclude that the unit digit of any perfect square belongs to the set $$\{\text{unit digit of $r^2$}: r\in \{0,1,2,3,4,5,6,7,8,9\}\}=\{0,1,4,9,6,5\}.$$

P.S. As regards the original question, a product of two consecutive integers has a unit digit $6$ iff we multiply factors with unit digits $2$ and $3$, or $7$ and $8$. It follows that none of these factors can be a perfect square.

Related Question