<s>[INST] calculating mod 7 Problem: Calculate $10^{10^{10}} \pmod 7$
According to Fermat's little theorem: $a^{p-1}\equiv1 \pmod p$, so $10^6\equiv1 \pmod 7$ and $10^n\equiv4 \pmod 6$, $n$ being any integer, why can we write $10^{10^{10}}\equiv10^4 \pmod 7$?
Similarly, if it's $10^n\equiv1 \pmod 3$, n being any integer, then wouldn't the equation become $10^{10^{10}}\equiv10^1\equiv3\pmod 7$? 
I'm confused on the translation phase.
Thanks
 [/INST] I believe your argument is correct. To compute $10^{10^{10}} \pmod{7}$ you can first compute $10^{10} \pmod{6}$. In turn, you can do this modulo $2$ and $3$, so you get that $10^{10} \equiv 4 \pmod{6}$, and $10^{10^{10}} \equiv 3^{4} \equiv 2 \cdot 2 \equiv 4 \pmod{7}$.
</s>