Fix modpow data type [closes #55]
This commit is contained in:
parent
64e7fab904
commit
dad48aca8f
|
@ -432,7 +432,7 @@ $x^n \bmod m$:
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
int modpow(int x, int n, int m) {
|
int modpow(int x, int n, int m) {
|
||||||
if (n == 0) return 1%m;
|
if (n == 0) return 1%m;
|
||||||
int u = modpow(x,n/2,m);
|
long long u = modpow(x,n/2,m);
|
||||||
u = (u*u)%m;
|
u = (u*u)%m;
|
||||||
if (n%2 == 1) u = (u*x)%m;
|
if (n%2 == 1) u = (u*x)%m;
|
||||||
return u;
|
return u;
|
||||||
|
|
Loading…
Reference in New Issue