From 2a15385d269653252c3a590ac69eb9ffb48dd796 Mon Sep 17 00:00:00 2001 From: Casper S Date: Mon, 23 May 2022 10:05:19 +0200 Subject: [PATCH] Add 0 check for primality test as per issue post --- src/math/miller_rabin.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/math/miller_rabin.rs b/src/math/miller_rabin.rs index 14e4694c838..650222e2a39 100644 --- a/src/math/miller_rabin.rs +++ b/src/math/miller_rabin.rs @@ -40,6 +40,9 @@ pub fn miller_rabin(number: u64, bases: &[u64]) -> u64 { // note that all bases should be prime if number <= 4 { match number { + 0 => { + panic!("0 is invalid input for Miller-Rabin. 0 is not prime by definition, but has no witness"); + } 2 => return 0, 3 => return 0, _ => return number,