I had a problem that of calculation of a^b mod m
, is
possible using modular exponentiation but the problem i am having is that the b I have is of very large value , b > 2^63 - 1
so could we modify the modular exponentiation code
function modular_pow(base, exponent, modulus) result := 1 while exponent > 0 if (exponent mod 2 == 1): result := (result * base) mod modulus exponent := exponent >> 1 base = (base * base) mod modulus return result
to accomodate for such a large b
or is it correct that a^b mod m
is equal to (a^(b mod m)) mod m
?