Skip to content

Instantly share code, notes, and snippets.

@krishnabhargav
Created July 25, 2014 01:29
Show Gist options
  • Save krishnabhargav/ae68e7c49e40b4c616cb to your computer and use it in GitHub Desktop.
Save krishnabhargav/ae68e7c49e40b4c616cb to your computer and use it in GitHub Desktop.
factorial implementation in clojure
(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