Modular_arithmetic

Revision en1, by sonu007, 2017-07-08 06:21:39

int modpow(int x, int n, int m) { if (n == 0) return 1%m; int u = modpow(x,n/2,m); u = (u*u)%m; if (n%2 == 1) u = (u*x)%m; return u; }

Please explain modpow(x, n/2, m) call again and again when below its code execute.

Tags modular arithmetic

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English sonu007 2017-07-08 06:21:39 244 Initial revision (published)