Skip to content

Instantly share code, notes, and snippets.

@michalmarczyk
Created June 18, 2010 23:03
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 michalmarczyk/444341 to your computer and use it in GitHub Desktop.
Save michalmarczyk/444341 to your computer and use it in GitHub Desktop.
;;; how come the first version seems to be faster...?
(defn fact [n]
(loop [n n r 1]
(if (zero? n)
r
(recur (dec' n) (*' r n)))))
(defn ^:static fact ^long [^long n]
(loop [n n r 1]
(if (zero? n)
r
(recur (dec' n) (*' r n)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment