RosettaCodeData/Task/Factorial/Emacs-Lisp/factorial-2.l
2020-02-17 23:21:07 -08:00

8 lines
331 B
Common Lisp

;; Recursive:
(defun fact (n)
"Return the factorial of integer N, which require to be positive or 0."
(if (not (and (integerp n) (>= n 0))) ; see above
(error "Function fact (N): Not a natural number or 0: %S" n))
(cond ; (or use an (if ...) with an else part)
((or (= n 0) (= n 1)) 1)
(t (* n (fact (1- n))))))