Created
April 6, 2016 19:15
-
-
Save CAYdenberg/63d310fcf39b8fdcd48eebbdb2919fdd to your computer and use it in GitHub Desktop.
Fibonacci function in clojure
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 fibonacci | |
([max sofar] | |
(def nextnum (+ (first (rseq sofar)) (second (rseq sofar)))) | |
(if (< nextnum max) | |
(fibonacci max (conj sofar nextnum)) | |
sofar)) | |
([max] | |
(fibonacci max [1, 1]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment