Created
October 9, 2012 22:40
-
-
Save thiagofm/3861912 to your computer and use it in GitHub Desktop.
fib clojure 2
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-rec | |
[ list-fib n ] | |
(if | |
(not= n 2) | |
(fib-rec (conj list-fib (reduce + (take-last 2 list-fib))) (- n 1)) list-fib) | |
) | |
(defn fib | |
[ n ] | |
(fib-rec [0 1] n) | |
) | |
(fib 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment