Last active
August 29, 2015 11:09
-
-
Save SohanChy/36f69d10c8032cd37ff8 to your computer and use it in GitHub Desktop.
NEED TO UNDERSTAND
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int bigmod(int a, int p, int m) | |
{ | |
int res = 1; | |
int x = a; | |
while(p) { | |
if(p&1) //odd | |
{ | |
res =(long long) (res*x)%m; | |
} | |
//even | |
x = (x*x)%m; | |
p>>=1; //Divide by two using right shift by 1 | |
} | |
return res; | |
} | |
int main() { | |
int hello = bigmod(57,153,11); | |
printf("%d",hello); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment