<s>[INST] Modular maths: How do I find the remainder? How do I find the remainder of $5^{22} \pmod{25}$?
And also how do I find the remainder of $3^{16} + 7 \pmod{5}$?
 [/INST] Well $5^3 = 125 \equiv -1 \pmod {7}$   because $7 \mid 125 - (-1)$
And since ${5}^{3} \equiv -1 \pmod {7}$ then ${(5^3)}^{7} \equiv (-1)^7 \pmod{7}$ and so $5^{21} \equiv -1 \pmod{7}$ and so $5^{22} \equiv -5 \pmod 7$. But since $-5 \equiv 2 \pmod 7$ then $5^{22} \equiv 2 \pmod 7$ as well
</s>