Created
July 16, 2011 23:13
-
-
Save scottlowe/1086906 to your computer and use it in GitHub Desktop.
Clojure function which returns the first X fibonacci numbers
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 [max] | |
(loop [a 1, b 1, acc [1]] | |
(if (>= (count acc) max) | |
acc | |
(recur b (+ a b) (conj acc b))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment