diff --git a/src/uu/factor/src/miller_rabin.rs b/src/uu/factor/src/miller_rabin.rs index 330c8f127..f909f1ec1 100644 --- a/src/uu/factor/src/miller_rabin.rs +++ b/src/uu/factor/src/miller_rabin.rs @@ -101,10 +101,14 @@ pub(crate) fn test(m: A) -> Result { Prime } -// Used by build.rs' tests +// Used by build.rs' tests and debug assertions #[allow(dead_code)] pub(crate) fn is_prime(n: u64) -> bool { - test::>(Montgomery::new(n)).is_prime() + if n % 2 == 0 { + n == 2 + } else { + test::>(Montgomery::new(n)).is_prime() + } } #[cfg(test)]