5 lines
191 B
Text
5 lines
191 B
Text
(define factorial (lambda (n)
|
|
(cond
|
|
((negative? n) (! "Negative inputs to factorial are invalid"))
|
|
((zero? n) 1)
|
|
(else (reduce (lambda (num acc) (* num acc)) 1 (range n 1))))))
|