Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static long moduloexpo2(long x, int n, int p) {
- long resul = 0;
- if(n == 1){
- resul = modulo2(x, p);
- }else{
- int i = (int)(n/2);
- cpt ++;
- if(n == 2*i){
- long temp = moduloexpo2(x,i,p);
- resul = modulo2(temp*temp, p);
- cpt += 1;
- }else{
- long temp = moduloexpo2(x,i,p);
- resul = modulo2(modulo2(x,p)*temp*temp, p);
- cpt += 2;
- }
- }
- return resul;
- }
Add Comment
Please, Sign In to add comment