How do you find reminder of $m^{x}$ divided by $n$ using Euler's and Fermat's little theorem? Can anyone show me step-by-step how to apply Fermat's little theorem and Euler's theorem?
Example: What is the remainder of $59^{28}$ divided by $7$?
The following is the way I know how to do these types of problems:
$59^{28} = (56+3)^{28}$... since $7|56$ then we are left with
$3^{28} = 3^{2*2*7} = 3^{4*7} = 81^{7} = (77+4)^{7}$... since $7|77$ then we are left with
$4^{7} = 4^3*4^{4} = 64*4^{4} = (63+1)*4^{4}$... since $7|63$ then we are left with
$1*4^{4} = 4^4 = 4^3*4 = 64*4 = (63+1)*4$... since $7|63$ then we are left with 4
Since we are left with just 4, we can just do: $4\mod{7} = 4$
So the remainder is 4!