TITLE: Modular exponentiation using Euler’s theorem
QUESTION [11 upvotes]: How can I calculate $27^{41}\ \mathrm{mod}\ 77$ as simple as possible?
I already know that $27^{60}\ \mathrm{mod}\ 77 = 1$ because of Euler’s theorem:
$$ a^{\phi(n)}\ \mathrm{mod}\ n = 1 $$
and
$$ \phi(77) = \phi(7 \cdot 11) = (7-1) \cdot (11-1) = 60 $$
I also know from using modular exponentiation that $27^{10} \mathrm{mod}\ 77 = 1$ and thus
$$ 27^{41}\ \mathrm{mod}\ 77 = 27^{10} \cdot 27^{10} \cdot 27^{10} \cdot 27^{10} \cdot 27^{1}\ \mathrm{mod}\ 77 = 1 \cdot 1 \cdot 1 \cdot 1 \cdot 27 = 27 $$
But can I derive the result of $27^{41}\ \mathrm{mod}\ 77$ using $27^{60}\ \mathrm{mod}\ 77 = 1$ somehow?

REPLY [3 votes]: By little Fermat: $\; 6,10\:|\:120\ \Rightarrow\ 3^{120} \equiv 1 \pmod{7, 11}\ \Rightarrow\ 3^{123} \equiv 3^3 \pmod{77}$
See also these Fermat-Euler-Carmichael generalizations of little Fermat-Euler from my sci.math post on Apr 10 2009.
THEOREM 1 $\ $ For naturals $\rm\: a,e,n\: $ with $\rm\: e,n>1 $
$\rm\qquad\qquad\ n\ |\ a^e-a\ $ for all $\rm\:a\ \iff\ n\:$ is squarefree and prime $\rm\: p\:|\:n\: \Rightarrow\: p-1\ |\ e-1 $
REMARK $\ $ The special case  $\rm\:e \:= n\:$ is Korselt's criterion for Carmichael numbers.
THEOREM 2 $\ $   For naturals $\rm\: a,e,n \:$ with $\rm\: e,n>1 $
$\rm\qquad\qquad\ n\ |\ a^e-1\ $ for all $\rm\:a\:$ coprime to $\rm\:n\ \iff\  p\:$ prime, $\rm\ p^k\: |\: n\ \Rightarrow\ \lambda(p^k)\:|\:e $
with $\rm\quad\ \lambda(p^k)\ =\ \phi(p^k)\ $ for odd primes $\rm\:p\:,\:$ or $\rm\:p=2,\ k \le 2 $
and  $\quad\ \ \rm \lambda(2^k)\ =\ 2^{k-2}\ $ for $\rm\: k>2 $
The latter exception is due to $\rm\:\mathbb Z/2^k\:$ having multiplicative group $\rm\ C(2) \times C(2^{k-2})\ $ for $\rm\:k>2\:.$
Note that the least such exponent $\rm\:e\:$ is given by $\rm\: \lambda(n)\: =\: lcm\ \{\lambda(\;{p_i}^{k_i})\}\;$ where $\rm\ n = \prod {p_i}^{k_i}\:.$
$\rm\:\lambda(n)\:$ is called the (universal) exponent of the group $\rm\:\mathbb Z/n^*,\:$ a.k.a. the Carmichael function.
See my post here for proofs and further discussion.