Skip to content

Instantly share code, notes, and snippets.

@pedrochaves
Last active January 14, 2020 21:02
Show Gist options
  • Save pedrochaves/1a47615b26d50f35983b9390a45b14d4 to your computer and use it in GitHub Desktop.
Save pedrochaves/1a47615b26d50f35983b9390a45b14d4 to your computer and use it in GitHub Desktop.
Fibonacci em Clojure
(defn !
[number]
(reduce * 1 (range 1 (inc number))))
#(reduce * 1 (range 1 (inc %)))
(defn !
[number]
(loop [current number
factorial number]
(if (= current 1)
factorial
(let [next-number (dec current)]
(recur next-number (* factorial next-number))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment