<s>[INST] What will be the remainder when $2^{31}$ is divided by $5$? The question is given in the title:

Find the remainder when $2^{31}$ is divided by $5$.

My friend explained me this way:

$2^2$ gives $-1$ remainder.
So, any power of $2^2$ will give $-1$ remainder.
So, $2^{30}$ gives $-1$ remainder.
So, $2^{30}\times 2$ or $2^{31}$ gives $3$ remainder.

Now, I cannot understand how he said the last line. So, please explain this line.
Also, how can I do this using modular congruency?
 [/INST] We have that $5$ is a prime, so, $2^4 \equiv 1 \pmod 5$ (see Fermat's little theorem).
Then, $(2^4)^{7} = 2^{28} \equiv 1 \pmod 5$. Multiplying this by $2^3$, we get $2^{31} \equiv 8 \equiv 3 \pmod 5$.
Your friend is saying that:
$$2^{30} \equiv -1 \pmod 5 \implies 2^{31} \equiv -1 \times 2 \equiv -2 \equiv -2 + 5 \equiv 3 \pmod 5.$$ 
</s>