Factorial in Lisp
Example for versions
Clojure 1.0.0,
Clojure 1.1.0
To calculate factorial of a number, one can create a range of numbers from 2 to this number and calculate the product of these numbers (function apply
).
(doseq [i (range 17)]
(println (str (str i "! = ") (apply * (range 2 (inc i))))))
Comments
]]>blog comments powered by Disqus
]]>