I am attempting to solve two problems. The first is to compute, in linear time, a^(b^c) mod p. The hint is to use Fermat's Little Theorem to simplify the problem.
The second problem is to simplify 5^596 mod 599.
These problems seem so easy, and yet their solutions esacape me.
In the first problem, I cannot simplify a^(b^c) mod p using Fermat's Little Theorem. Somehow I need to manipulate the problem to the form of:
( a^(p-1) * a^(p-1) * ... * a^x) mod p
Can anyone offer suggestions or guidance on these two problems?
Thank you in advance for your help.