Created
October 7, 2015 17:48
-
-
Save sinanduman/67f663f203bc2c2cf5d3 to your computer and use it in GitHub Desktop.
Fibonacci numbers with tail recursion optimization
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 | |
([n] | |
(fib n 0 1 0) ) | |
([n start prev acc] | |
(if (= n start) | |
acc | |
(fib n (inc start) acc (+ prev acc ) ) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment