Skip to content

Commit

Permalink
Improved mod_pow() speed by 15%
Browse files Browse the repository at this point in the history
  • Loading branch information
craigmayhew committed Feb 21, 2024
1 parent e3b428f commit 423b673
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pages/primalitytest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn modpow(a: u64, mut exp: u64, n: u64) -> u64 {
// if exponent is odd
t = modmult(t, f, n);
}
exp = (exp as f64 / 2.0).floor() as u64;
exp >>= 1;
f = modmult(f, f, n);
}
modmult(t, f, n)
Expand Down

0 comments on commit 423b673

Please sign in to comment.