RosettaCodeData/Task/Factorial/CLIPS/factorial.clips

9 lines
228 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(deffunction factorial (?a)
(if (or (not (integerp ?a)) (< ?a 0)) then
(printout t "Factorial Error!" crlf)
else
(if (= ?a 0) then
1
else
(* ?a (factorial (- ?a 1))))))