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.
 A: By Euler's Theorem, we have $2^{12}\equiv 1\pmod{21}$. That is because $\varphi(21)=(2)(6)=12$. Thus $2^{25}=2^{12\cdot 2}\cdot 2^1\equiv 2\pmod{21}$.
If we want to use Fermat's Theorem, we work separately modulo $3$ and modulo $7$.
We have $2^2\equiv 1\pmod{3}$, and therefore $2^{25}=2^{2\cdot 12}\cdot 2^1\equiv 2\pmod{3}$.
Similarly, $2^6\equiv 1\pmod{7}$ and therefore $2^{25}\equiv 2\pmod{7}$.
It follows that $2^{25}\equiv 2\pmod{21}$.

Added: For the last two digits of $1+7^{162}+(5^{121})(3^{312})$, it will be enough to evaluate modulo $4$ and modulo $25$.
Modulo $4$: We have $7\equiv -1\pmod{4}$, so $7^{162}\equiv 1\pmod{4}$. Similarly, $5^{121}\equiv 1\pmod{4}$ and $3^{312}\equiv 1\pmod{4}$. Adding up, we get the sum is $\equiv 3\pmod{4}$.
Modulo $25$:  We don't have to worry about the messy last term. Note that $7^2\equiv -1\pmod{25}$, so $7^{160}\equiv 1\pmod{25}$. Thus $7^{162}\equiv -1\pmod{25}$. Thus our sum is congruent to $0$ modulo $25$.
Finally, we want the multiple of $25$ between $0$ and $75$ which is congruent to $3$ modulo $4$. A quick scan shows the answer is $75$. 
A: 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)?$
