$3^{123} \mod 100$ 
The Question:

Evaluate $3^{123}\mod 100$

My Attempt

So initially I attempted to list the powers of 3 and find a pattern of the last two digits - which, despite much painful inspection did not yield an obvious useful pattern.
So I then attempted to simplify this and use Euler's Generalisation of Fermat's Theorem to solve this:
The theorem states: $a^{\phi(n)} \equiv 1 \pmod{n}$
So:
$3^{123}\mod 100$
= $3^{41^3}\mod 100$
= $(3^{40} \times 3^1)^3\mod 100$
I think I'm ok up to that point. Now, $\phi(100) = 40$
So am I right in the following?
$(3^{40} \times 3^1)^3\mod 100$ $\cong$ $(1 \times 3^1)^3\mod 100$
= $3^3\mod 100$
= 27.
Am I correct?

Thanks!


The OP began by looking for a pattern but stated
that

...despite much painful inspection did not yield an obvious useful pattern.

You can use some light theory to actually predict the form and structure of the pattern.
Observe that if $a \in \{0,2,4,6,8\}$ and $b \in  \{1,3,7,9\}$ and
$\quad 3 \times (10 a + b) \equiv 10 \,a' + b' \pmod{100} \text{ with } a',b' \in \{0,1,2,3,4,5,6,7,8,9\}$
then in fact $a' \in \{0,2,4,6,8\}$ and $b' \in  \{1,3,7,9\}$.
This is our main (theoretical) pattern and
$\quad 3^1 \equiv 03 \pmod{100}$
$\quad 3^2 \equiv 09 \pmod{100}$
$\quad 3^3 \equiv 27 \pmod{100}$
$\quad 3^4 \equiv 81 \pmod{100}$
$\quad\text{-------------------------}$
$\quad 3^5 \equiv 43 \pmod{100}$
It easy to verify that the units digit will move
$\quad 3 \mapsto 9 \mapsto 7 \mapsto 1$
inside each of these four cycles.
Considering that $3$ is a unit, we can argue that one of these $4$-cycles will end on
$$\quad 01 \quad \text{the multiplicative identify}$$
and that no repetition is possible until the identify is reached.
Since the tens digit can only cycle over the set $\{0,2,4,6,8\}$, there are at most five of these $4$-cycles that have to be calculated.
Calculating the $2^{nd}$ $4$-cycle:
$\quad 3^5 \equiv 43 \pmod{100}$
$\quad 3^6 \equiv 29 \pmod{100}$
$\quad 3^7 \equiv 87 \pmod{100}$
$\quad 3^8 \equiv 61 \pmod{100}$
$\quad\text{-------------------------}$
Calculating the $3^{rd}$ $4$-cycle:
$\quad 3^9 \equiv 83 \pmod{100}$
$\quad 3^{10} \equiv 49 \pmod{100}$
$\quad 3^{11} \equiv 47 \pmod{100}$
$\quad 3^{12} \equiv 41 \pmod{100}$
$\quad\text{-------------------------}$
Calculating the $4^{th}$ $4$-cycle:
$\quad 3^{13} \equiv 23 \pmod{100}$
$\quad 3^{14} \equiv 69 \pmod{100}$
$\quad 3^{15} \equiv 07 \pmod{100}$
$\quad 3^{16} \equiv 21 \pmod{100}$
$\quad\text{-------------------------}$
At this point we really don't have to calculate the  $5^{th}$ $4$-cycle since we know it has to be the last one.
We can now use the fact that
$\tag 1 3^{20} \equiv 1 \pmod{100}$
and work out the remaining details for the OP's question.
