Question about Fermat's Theorem I'm trying to find $2^{25} \mod 21 $. By Fermat's theorem, $2^{20} \cong_{21} 1 $. Therefore, $2^{25} = 2^{20}2^{5} \cong_{21} 2^5 = 32 \cong_{21} 11 $. However, the answer in my book is $2$! What am I doing wrong?
Also, I would like to ask what are the last two digits of $1 + 7^{162} + 5^{121} \times 3^{312} $
Thanks for your help.

As $21$ is not prime we can use Carmichael function  to show that $2^6\equiv1\pmod{21}$
In fact, $2^6=64\equiv1\pmod{21}$
$\displaystyle \implies 2^{25}=2\cdot(2^6)^4\equiv2\cdot1^4\pmod{21}$

For the last two digits of $1+7^{162}+(5^{121})(3^{312}),$
we need $1+7^{162}+(5^{121})(3^{312})\pmod{100}$
Now, observe that  $\displaystyle7^2=49=50-1$
$\implies7^4=(50-1)^2=50^2-2\cdot50\cdot1+1^2\equiv1\pmod{100}$
$\displaystyle \implies 7^{162}=7^2\cdot(7^4)^{40}\equiv49\cdot1^{40}\pmod{100}\equiv49\ \ \ \ (1)$
Again, $5^{a+b}-5^a=5^a(5^b-1)\equiv0\pmod{100}$ if integer $a\ge2,b\ge0$
$\displaystyle \implies 5^{121}\equiv5^2\pmod{100}\equiv25=100c+25$(say) where $c$ is some integer
and $3\equiv-1\pmod4\implies 3^{312}\equiv(-1)^{312}\pmod4\equiv1=4d+1$  where $d$ is some integer
$\displaystyle \implies 5^{121}\cdot3^{312}=(100c+25)(4d+1)\equiv25\pmod{100}\ \ \ \ (2) $
Can you take it from here using $(1),(2)?$
