7 lines
197 B
Text
7 lines
197 B
Text
|
|
(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))))))
|