Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. T modpow(T base, T exp, T modulus) {
  2. base %= modulus;
  3. T result = 1;
  4. while (exp > 0) {
  5. if (exp & 1) result = (result * base) % modulus;
  6. base = (base * base) % modulus;
  7. exp >>= 1;
  8. }
  9. return result;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement