Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc expmod(a, n, m)
- res := 1;
- repeat
- if n is odd
- n := n - 1;
- res := (res * a) mod m;
- else
- n := n / 2;
- a := (a * a) mod m;
- end if;
- until n = 0;
- return res;
- end proc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement