Skip to content

Commit bba62af

Browse files
committed
Fixed mistake
1 parent 88fb6d0 commit bba62af

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/math.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use std::mem::swap;
44

55
#[allow(clippy::many_single_char_names)]
66
pub fn pow_mod(x: i64, mut n: i64, m: u32) -> u32 {
7-
assert!(0 <= n && 1 <= m);
8-
7+
assert!(0 <= n && 1 <= m && m <= 2u32.pow(31));
8+
if m == 1 {
9+
return 0;
10+
}
911
let bt = internal_math::Barrett::new(m);
1012
let mut r = 1;
1113
let mut y = internal_math::safe_mod(x, m as i64) as u32;

0 commit comments

Comments
 (0)