Two days ago I asked about how to solve questions of the type:
Find last digit of $27^{27^{26}}$.
or
Find the remainder when $27^{45}$ is divided by $7$, using congruences.
I have now got this method completely, but I am still not able to solve these types of questions through Fermat's theorem. If somebody can solve one of the above problem step by step through Fermat's theorem or at least can give me some hint or provide anything that can be useful for me in solving these questions (if not direct solution) then it would be of tremendous help for me.