Created
October 30, 2013 16:57
-
-
Save podviaznikov/7236147 to your computer and use it in GitHub Desktop.
Fibonacci implementation on Clojure.
This file contains 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 fib-iter [a b n] | |
(if (zero? n) | |
b | |
(recur (+ a b) a (dec n)))) | |
(defn fib [n] | |
(fib-iter 1 0 n)) | |
(fib 40) ;102334155 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment