Advertisement
Mijyuoon

expmod() p/c

Sep 27th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. proc expmod(a, n, m)
  2. res := 1;
  3. repeat
  4. if n is odd
  5. n := n - 1;
  6. res := (res * a) mod m;
  7. else
  8. n := n / 2;
  9. a := (a * a) mod m;
  10. end if;
  11. until n = 0;
  12. return res;
  13. end proc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement