We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08fbf92 commit 4cc3d64Copy full SHA for 4cc3d64
bundles/03-math-1/03_math1.pdf
15.9 KB
bundles/03-math-1/latex/03_math1.tex
@@ -1356,7 +1356,7 @@ \subsection{Fast Exponentiation Approach }
1356
// If k is odd return n * temp * temp
1357
// If k is even return temp * temp
1358
// Take mod, since we can have a large number that overflows from long long
1359
- if((k&1) == 1) return (n * temp * temp) % mod
+ if((k&1) == 1) return ((n * temp) % mod * temp) % mod;
1360
return (temp * temp) % mod;
1361
}
1362
int main() {
0 commit comments