Created
July 25, 2014 01:29
-
-
Save krishnabhargav/ae68e7c49e40b4c616cb to your computer and use it in GitHub Desktop.
factorial implementation in clojure
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 [number] | |
(loop [num (biginteger number) | |
acc 1] | |
(if (zero? num) acc | |
(recur (dec num) (* acc num))))) | |
;; factorial can now be called on any large numbers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment