RosettaCodeData/Task/Primality-by-Wilsons-theorem/Common-Lisp/primality-by-wilsons-theorem.lisp
2023-07-01 13:44:08 -04:00

8 lines
193 B
Common Lisp

(defun factorial (n)
(if (< n 2) 1 (* n (factorial (1- n)))) )
(defun primep (n)
"Primality test using Wilson's Theorem"
(unless (zerop n)
(zerop (mod (1+ (factorial (1- n))) n)) ))