Factorial (lazy sequence)
;;; Factorial (lazy sequence)
(defun fact(n)
"Compute factorial"
(apply #'* (range 1 (+ n 1))))
(println "5! = " (fact 5))
Output:
5! = 120
;;; Factorial (lazy sequence)
(defun fact(n)
"Compute factorial"
(apply #'* (range 1 (+ n 1))))
(println "5! = " (fact 5))
Output:
5! = 120