Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T modpow(T base, T exp, T modulus) {
- base %= modulus;
- T result = 1;
- while (exp > 0) {
- if (exp & 1) result = (result * base) % modulus;
- base = (base * base) % modulus;
- exp >>= 1;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement