Skip to content

Instantly share code, notes, and snippets.

@timmc
Forked from thiagofm/fib2.clj
Created October 9, 2012 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmc/3861930 to your computer and use it in GitHub Desktop.
Save timmc/3861930 to your computer and use it in GitHub Desktop.
fib clojure 2
(defn fib
([n]
(fib [0 1] (- n 2)))
([list-fib n]
(if (zero? n)
list-fib
(recur (conj list-fib (apply + (take-last 2 list-fib)))
(dec n)))))
(fib 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment