Powers Modulo m

$\blacktriangleright$ To calculate large powers modulo m

Define a = 2789596378267275, n = 3848590389047349, and m = 2838490563537459.


$\blacktriangleright$ Evaluate

an$\limfunc$modm = 26220 18141 09828


Fermat's Little Theorem states that, if p is prime and 0 < a < p, then

ap-1$\displaystyle \limfunc$modp = 1

The integer 1009 is prime, and the following is no surprise.


$\blacktriangleright$ Evaluate

21008$\limfunc$mod1009 = 1