0

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!

lucidgold
  • 1,054

1 Answers1

0

Applying Fermat's little theorem:

$$ \begin{align*} 7 \not\mid 59 &\implies 59^{6} \equiv 1 \pmod{7} \\ &\implies 59^{28} \equiv 59^{6(4) + 4} \equiv (59^6)^459^{4} \equiv 1^459^4 \equiv 59^4 \equiv 3^4\equiv 4\pmod{7} \end{align*} $$

Applying Euler's theorem: $$ \begin{align*} \gcd(59,7) = 1 &\implies 59^{6} \equiv 1 \pmod{7} \\ &\implies 59^{28} \equiv 59^{6(4) + 4} \equiv (59^6)^459^{4} \equiv 1^459^4 \equiv 59^4 \equiv 3^4\equiv 4\pmod{7} \end{align*} $$

The two theorems' applications are essentially the same here because Euler's theorem generalizes Fermat's little theorem from prime modulus to non-prime modulus. Since 7 is prime, Fermat's little theorem suffices.

Myath
  • 1,073
  • In Euler's theorem solution, how/why did you get from $59^{28}$ to $59^{6(4)+4}$? – lucidgold Oct 28 '15 at 21:30
  • $28 = 6(4) + 4 = 24+4.$ – Myath Oct 28 '15 at 21:32
  • Yes, but why isolate 6? – lucidgold Oct 28 '15 at 21:33
  • Euler's theorem gives that $59^6\equiv 1\pmod{7}$ and we want to make use of that fact. Therefore, we isolate 6 to get $59^6\equiv 1\pmod{7}$ since $1$ makes things easy. – Myath Oct 28 '15 at 21:34
  • So you recursively isolate 6 at each step? What happens if we have to find the remainder of $59^{2008}$ divided by $7$? We then have to isolate 6 A LOT of times!? – lucidgold Oct 28 '15 at 21:36
  • No, only one time. You would have $2008 = 6(334) + 4$ and $59^{2008}\equiv (59^6)^{334}59^4 \equiv 1^{334}59^4 \equiv 3^4 \pmod{7}$ – Myath Oct 28 '15 at 21:38
  • Okay, I think I am starting to understand. But how did you get from $59^4 \equiv 3^4$ then from $3^4 \equiv 4\pmod{7}$? At this point you can no longer extract a power of 6? – lucidgold Oct 28 '15 at 21:54
  • You can no longer extract a power of 6 when the power is less than 6. $59^4 \equiv 3^4 \pmod{7}$ because $59\equiv 3\pmod{7}$, and $3^4 = 81 \equiv 4\pmod{7}$ is just straight computation. – Myath Oct 28 '15 at 23:48