From 0eefb230650ae97dd9ac5934ff656329156fc386 Mon Sep 17 00:00:00 2001 From: dieggsy Date: Mon, 26 Apr 2021 16:57:18 -0400 Subject: [PATCH] Ensure lisp miller rabin doesn't trip up on zero --- sbcl/numbers.lisp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbcl/numbers.lisp b/sbcl/numbers.lisp index dc12a5a..717610d 100644 --- a/sbcl/numbers.lisp +++ b/sbcl/numbers.lisp @@ -52,7 +52,8 @@ (defun miller-rabin (n k) "Test N for primality by performing the Miller-Rabin test K times. Return NIL if N is composite, and T if N is probably prime." - (cond ((= n 1) nil) + (cond ((zerop n) nil) + ((= n 1) nil) ((< n 4) t) ((evenp n) nil) (t -- 2.38.4