Find the least positive integer $M$ such that $M^{77} \equiv 14 \pmod{31}.$
The way I have approached this question is by using Fermat's little theorem:
$$a^{p-1} \equiv 1 \pmod p. $$
By trial and error -- I just started at $1$, then $2$, etc. -- eventually $M=18$ was the first integer (least positive) that gave the result congruent to $14$ mod $31$:
$$18^{30} \equiv 1 \pmod{31}.$$ $$ 18^{77} = 18^{2\cdot 30+17} \equiv 18^{17} \equiv 14 \pmod{31}.$$
This way of solving it is obviously quite long and tedious (especially without a calculator). I am wondering if anybody can explain to me a more appropriate approach.
Well $31$ is prime so if $\gcd(31,M) \ne 1$ then $M^{77} \equiv 14 \pmod {31}$ will never happen.
So for any $M$ were $M^{77}\equiv 14$ then $M$ is relatively prime to $31$ and $M^{30}\equiv 1$ and $M^{77} \equiv M^{17}\equiv 14\pmod {31}$.
Now if we can do $17*k \equiv 1 \pmod {30}$ we can do $M^{17k}\equiv M \equiv 14^k\pmod {31}$.
And the rest is busy work....
And Euclid's Algorithm or other method [1] gives us $23*17\equiv 1 \pmod {30}$ so
$M \equiv 14^{23}$ which we can reduce.
$2^5 \equiv 1 \pmod {31}$ and $7^3 \equiv 2\pmod {31}$
So $14^{23} \equiv 2^{23}*7^{23}\equiv 2^3*(7^3)^7*7^2\equiv 2^3*2^7*49\equiv 2^{10}*18\equiv 18\pmod{31}$
....
[1] Other method, in my case, is guessing. $3*17 = 51$ and we need last digit $1$ and that can only be if we do $17*(3 + 10a)$ and there are only three chooses for $a$