Skip to content

Instantly share code, notes, and snippets.

@thiagofm
Created October 9, 2012 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thiagofm/3861912 to your computer and use it in GitHub Desktop.
Save thiagofm/3861912 to your computer and use it in GitHub Desktop.
fib clojure 2
(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