What is $2018^{2018}$ mod $20$? The answer is $4$.
I saw someone answered in $5$ seconds. How did they do that?

Since $2018 \equiv -2 \pmod{20}$ we have $$2018^{2018} \equiv (-2)^{2018} \equiv 4^{1009}\pmod{20}$$
and then
$$4^1 \equiv 4 \pmod{20} \\ 4^2 = 16 \equiv -4 \pmod{20} \\ 4^3 \equiv -4\cdot 4 \equiv 4 \pmod{20} \\ \vdots$$
Since $1009$ is odd and the powers of $4$ alternate $4, -4, 4, -4, \ldots$, the answer is $4.$
