Created
November 22, 2012 11:25
-
-
Save harveytoro/4130673 to your computer and use it in GitHub Desktop.
Modular Exponentiation Java method
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
public static int modpow(int value , int power, int mod){ | |
int e = 1; | |
for (int i = 0; i < power; i++) { | |
e = ((e * value) % mod); | |
} | |
return e; | |
}//modpow | |
/* | |
((value^power)%mod) | |
call as modpow(value, power, mod); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment