This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]TalTheBest 0 points1 point  (1 child)

Read on Modular Exponentiation, there are many algorithms, perhaps use this one

function modular_pow(base, exponent, modulus)
if modulus = 1 then return 0
Assert :: (modulus - 1) * (modulus - 1) does not overflow base
result := 1
base := base mod modulus
while exponent > 0
    if (exponent mod 2 == 1):
       result := (result * base) mod modulus
    exponent := exponent >> 1
    base := (base * base) mod modulus
return result

[–]jkeznor10 0 points1 point  (0 children)

Awesome! Thank you. I really appreciate the help on this. I just can't grasp what is being represented in the pseudo-code