Skip to content

Commit 4cc3d64

Browse files
committed
Fix integer overflow in bundle 03
1 parent 08fbf92 commit 4cc3d64

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

bundles/03-math-1/03_math1.pdf

15.9 KB
Binary file not shown.

bundles/03-math-1/latex/03_math1.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ \subsection{Fast Exponentiation Approach }
13561356
// If k is odd return n * temp * temp
13571357
// If k is even return temp * temp
13581358
// Take mod, since we can have a large number that overflows from long long
1359-
if((k&1) == 1) return (n * temp * temp) % mod
1359+
if((k&1) == 1) return ((n * temp) % mod * temp) % mod;
13601360
return (temp * temp) % mod;
13611361
}
13621362
int main() {

0 commit comments

Comments
 (0)