mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-26 07:04:27 +00:00
8 lines
231 B
Plaintext
8 lines
231 B
Plaintext
;; Functions to calculate factorial
|
|
|
|
;; Recursive version, not tail call optimized
|
|
(def recFact (fn (n) (if (< n 2) 1 (* n (recFact (- n 1))))))
|
|
|
|
;; Apply version
|
|
(def applyFact (fn (n) (if (< n 2) 1 (apply * (range 1 (+ n 1))))))
|