<s>[INST] Proof that $x^{(n+4)} \bmod 10 = x^n \bmod 10\,$ for $\,n\ge 1$ While solving a programming challenge in which one should efficiently compute the last digit of $a^b$, I noticed that apparently the following holds (for $n > 0$)
$x^{(n+4)} \mod 10 = x^n \mod 10$
How can this be proven?
 [/INST] We want to show that $x^{n+4}-x^n=x^n(x^4-1)$ is a multiple of $10$. 
We first notice that if $x^n$ is odd then $x^4-1$ will be even and vice versa. Consequently, the product will always be even.
If $x$ is divisible by $5$ then the product is divisible by $10$ because we have an even product which is divisible by $5$.
If $x$ is not divisible by $5$ then $x=5m+k$ for some $m$ and $k$ where $k\in\{1,2,3,4\}$.
Now, $x^4-1=(5m)^4+4(5m)^3k+6(5m)^2k^2+4(5m)k^3+k^4-1$ and every term is divisible by $5$ with the possible exception of $k^4-1$.
But there are only four values of $k$ and if you raise each to the fourth power and subtract $1$ you get a multiple of $5$. Once again, this gives us an even number divisible by $5$ which is a multiple of $10$.
</s>