Factorial in Lisp
Example for versions
Corman Common Lisp 3.0,
SBCL 1.0.1,
SBCL 1.0.29,
clisp 2.47,
gcl 2.6.6
In this example the inner loop with collect
clause produces a list of numbers from 1 to n
. After this operation *
is applied to this list, and the product of the numbers is printed.
(loop for n from 0 to 16
do (format t "~D! = ~D~%" n
(apply '* (loop for i from 1 to n
collect i)) ) )
Comments
]]>blog comments powered by Disqus
]]>