Skip to content

Instantly share code, notes, and snippets.

@crittermike
Created January 6, 2012 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crittermike/1570886 to your computer and use it in GitHub Desktop.
Save crittermike/1570886 to your computer and use it in GitHub Desktop.
(defn factorial [n]
(if (< n 2)
1
(* n (factorial (dec n)))))
(defn factorial [x]
(loop [n x f 1]
(if (= n 1) f
(recur (dec n) (* f n)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment