Created
March 22, 2020 16:14
-
-
Save dominem/ed61e80a43185efdf5ce1b4e53904d91 to your computer and use it in GitHub Desktop.
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] | |
(take n (fib 0 1))) | |
([a-2 a-1] | |
(cons a-1 (lazy-seq (fib a-1 (+ a-2 a-1)))))) | |
(comment | |
(fib 3) | |
;; => (1 1 2) | |
(fib 6) | |
;; => (1 1 2 3 5 8) | |
(fib 8) | |
;; => (1 1 2 3 5 8 13 21) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment