Why is there a pattern to the last digits of square numbers? I was programming and I realized that the last digit of all the integer numbers squared end in $ 0, 1, 4, 5, 6,$ or $ 9 $.
And in addition, the numbers that end in $ 1, 4, 9, 6 $ are repeated twice as many times as the numbers that end in $ 0, 5$
I checked the numbers from $1$ to $1000$, and the results are:
$1.$ The numbers on the left are the last digit of each digit squared.
$2.$ The numbers on the right are the number of times that the last digit is repeated.
$$
\begin{array}{cc}
0: &100, \\
1: &200, \\
4: &200, \\
5: &100, \\
6: &200, \\
9: &200
\end{array}
$$
So, why does this happen? What is the property that all integers have?

Note that any number can be written in the form $10a+(5 \pm b)$ where $0 \leq b \leq 5$. If n = $10a+(5 \pm b)$, then we can calculate $n^2$ as 
$(10a)^2+2(10a)(5 \pm b) + (5 \pm b)^2=$$100a^2 + 100a \pm 20ab+(5 \pm b)^2$
$100a^2$, $100a$, and $\pm 20ab$ are all divisible by 10, so we can ignore them, and we're left with $(5 \pm b)^2 = 25 \pm 10b +b^2$. Again, we can ignore $\pm10b$, and we can reduce 25 to 5, leaving $5+b^2$. Note that the $\pm$ part has disappeared; $(10a+(5 + b))^2$ has the same last digit as $(10a+(5 - b))^2$. So, normally, each value of $b$ gives the same remainder twice, once for $+b$ and once for $-b$. But if $b=0$, then $+b$ and $-b$ are the same number, so it gives the remainder only once. And if $b=5$, then $5-b$ gives 0, and $5+b$ gives 10, which also corresponds to a last digit of 0. 
So we have:
$b = 0$: last digit of $n$ is 5, last digit of $n^2$ is 5
$b = 1$: last digit of $n$ is 4 or 6, last digit of $n^2$ is 6
$b = 2$: last digit of $n$ is 3 or 7, last digit of $n^2$ is 9
$b = 3$: last digit of $n$ is 2 or 8, last digit of $n^2$ is 4
$b = 4$: last digit of $n$ is 1 or 9, last digit of $n^2$ is 1
$b = 5$: last digit of $n$ is 0, last digit of $n^2$ is 0
Hence, 0 and 5 show up once, while 1,4,6, and 9 show up twice.
