Skip to content

Instantly share code, notes, and snippets.

@TheEmpty
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save TheEmpty/9024541 to your computer and use it in GitHub Desktop.

Select an option

Save TheEmpty/9024541 to your computer and use it in GitHub Desktop.
(defun factorial (n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
(dotimes (x 10)
(let ((n (+ x 1)))
(format t "factorial ~2D = ~D~%" n (factorial n))))
; output
; factorial 1 = 1
; factorial 2 = 2
; factorial 3 = 6
; factorial 4 = 24
; factorial 5 = 120
; factorial 6 = 720
; factorial 7 = 5040
; factorial 8 = 40320
; factorial 9 = 362880
; factorial 10 = 3628800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment