How to use Fermat's Little theorem in $12^{12^{12}}\mod{17}$? [duplicate]

Solution 1:

The sentence

Therefore we calculate $12^{12}=144^6\equiv0^6(mod\ 16)=0$

is simply proving that $12^{12}$ is divisible by $16$.

After it's proven, we can state $12^{12}$ in the form $16k$ where $k$ is a positive integer. So,

$$12^{12^{12}}=12^{16k}=(12^{16})^k\equiv1^k=1(mod\ 17)$$