View Single Post
Old 2020-09-15, 16:06   #13
drmurat
 
"murat"
May 2020
turkey

7210 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
Code:
Mod(10,107)^100000000000000000000000000000000000000000
Mod(34, 107)

##
  ***   last result computed in 0 ms
.

It actually works by left-right binary exponentiation modulo n

And since 107 is prime we can use Fermat's little theorem:

Code:
Mod(10,107)^(100000000000000000000000000000000000000000%106)
Mod(34, 107)
Or simething even "bigger":

Code:
Mod(10,107)^(100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%106)
Mod(4, 107)

Thanks
drmurat is offline   Reply With Quote