Modular Exponentiation for high numbers in C++
Exponentiation by squaring still “works” for modulo exponentiation. Your problem isn’t that 2 ^ 168277 is an exceptionally large number, it’s that one of your intermediate results is a fairly large number (bigger than 2^32), because 673109 is bigger than 2^16. So I think the following will do. It’s possible I’ve missed a detail, but … Read more