We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88fb6d0 commit bba62afCopy full SHA for bba62af
src/math.rs
@@ -4,8 +4,10 @@ use std::mem::swap;
4
5
#[allow(clippy::many_single_char_names)]
6
pub fn pow_mod(x: i64, mut n: i64, m: u32) -> u32 {
7
- assert!(0 <= n && 1 <= m);
8
-
+ assert!(0 <= n && 1 <= m && m <= 2u32.pow(31));
+ if m == 1 {
9
+ return 0;
10
+ }
11
let bt = internal_math::Barrett::new(m);
12
let mut r = 1;
13
let mut y = internal_math::safe_mod(x, m as i64) as u32;
0 commit comments