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