RosettaCodeData/Task/Factorial/Slope/factorial-2.slope

7 lines
197 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(define factorial (lambda (n)
(cond
((negative? n) (! "Negative inputs to factorial are invalid"))
((zero? n) 1)
(else
(for ((acc 1 (* acc i))(i 1 (+ i 1))) ((<= i n) acc))))))