Skip to content

Instantly share code, notes, and snippets.

@SohanChy
Last active August 29, 2015 11:09
Show Gist options
  • Save SohanChy/36f69d10c8032cd37ff8 to your computer and use it in GitHub Desktop.
Save SohanChy/36f69d10c8032cd37ff8 to your computer and use it in GitHub Desktop.
NEED TO UNDERSTAND
#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