Last active
August 29, 2015 13:56
-
-
Save TheEmpty/9024541 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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