Created
August 17, 2012 01:19
-
-
Save scizo/3375107 to your computer and use it in GitHub Desktop.
recursive factorial
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
(defn factorial [n] | |
(loop [n n | |
tally 1] | |
(if (< n 1) | |
tally | |
(recur (dec n) (* n tally))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment