<s>[INST] Applying Fermat's Little Theorem: $6^{1987}$ divided by $37$ Find the remainder when $6^{1987}$ is divided by $37$.
Because 37 is prime we have: $6^{36}$ mod $37 = 1$. I tried to get a nice combination like: $1987 = 36 * 55 + 7$, so we would have $(6^{36})^{55}6^{7}=6^{1987}$.
Then, I've taken mod $37$, which is: $6^{1987}$ mod $37=1^{55}(6^7$ mod $37)$. I need to find $6^7$ mod $37$. What can I do from here?
Of course, any other method (solution) for finding the remainder would be great.
 [/INST] $$6^2\equiv-1\pmod{37}$$
So $6^7\equiv (-1)^3\cdot 6\equiv 31\pmod{37}$
You could have utilized this from the start, since $6^2\equiv-1\implies 6^4\equiv1$. Thus, you could have written $1987=496\cdot 4+3$ and $$6^{1987}=(6^4)^{496}\cdot6^3\equiv 6^3\equiv 6^26\equiv-6\equiv31\pmod{37}$$
</s>