Last active
January 14, 2020 21:02
-
-
Save pedrochaves/1a47615b26d50f35983b9390a45b14d4 to your computer and use it in GitHub Desktop.
Fibonacci em 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 ! | |
[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