<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] If you can prove $x^4 \equiv 1 \pmod {10}$ that's enough as $x^{n+4}\equiv x^n\cdot x^4 \equiv x^n\cdot 1\equiv x^n\pmod {10}$
If you google Euler's theorem that will be true for all numbers relatively prime to $10$.  Intuitively (but hand wavy) if $x$ and $10$ are relatively prime then $x^n$ will be relatively prime. There are only $4$ possible last digits that are relatively prime to $10$ so $x^k$ will cycle through the same four digits. (More or less.)
If $x$ is even or divisible by $5$. Well, if it's both then $x \equiv 0 \mod 10$ so $x^k \equiv 0 \pmod {10}$ and $x^{n+4} \equiv x^n \equiv 0\pmod {10}$.  Likewise if it's odd but divisible by $5$ then $x^k \equiv 5 \pmod{10}$ and so $x^{n+4} \equiv x^n \equiv 5 \pmod {10}$.
Now if $x$ is even but not divisible by $5$ then.  Well, $x^n$ is even and there are only $4$ even digits it could end with and it cycles through them.
More to the point $2*j \pmod 10 \equiv 2*(j \pmod 5)$ and there are only $4$ non-zero classes $\pmod 5$ so $x^k$ just cycles through those. 
</s>