[Math] Fermat’s Little Theorem Problem

elementary-number-theory

How can we use Fermat's Little Theorm to find the least non-negative residue modulo m with numbers with large exponents. For example, how would one find the least non-negative residue modulo m with values $n = 3^{1000000}$ and $m = 19$.

I understand how the basic method works (ie finding a way to introduce a factor of $3^{18}$ and then reducing), but dividing 1000000 by 18 is time consuming and I feel there is a quicker method that I don't understand yet.

Best Answer

$$3^{18}\equiv 1 \text{ mod 19}$$ $$3^{18*55555}\equiv 1 \text{ mod 19}$$ $$3^{999990}\equiv 1\text{ mod 19}$$ $$3^{1000000}\equiv 3^{10} \text{ mod 19}$$ $$3^{1000000}\equiv 16\text{ mod 19}$$

Related Question