Skip to content

Instantly share code, notes, and snippets.

@mrklein
Created September 16, 2012 13:36
Show Gist options
  • Save mrklein/3732492 to your computer and use it in GitHub Desktop.
Save mrklein/3732492 to your computer and use it in GitHub Desktop.
factorial
(defun factorial (n)
(defun i_factorial (n acc)
(if (= 0 n)
acc
(i_factorial (- n 1) (* acc n))))
(i_factorial n 1))
(defun print-factorial (n)
(format T "~D~%" (factorial n)))
(mapcar 'print-factorial '(1 12 123 1234 12345))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment