Created
June 27, 2016 20:58
-
-
Save melklein/acec538dcc120ca2c66c633bcd0f0a2b to your computer and use it in GitHub Desktop.
clojure recursion with 'mundane' recursion and 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-seq [x result] | |
(if (= x 0) | |
(reverse result) | |
(let [next-fib (reduce + (take 2 result))] | |
(fib-seq (dec x) (conj result next-fib))))) | |
(defn fib [mx] | |
(fib-seq (- mx 2) '(1 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment