Skip to content

Instantly share code, notes, and snippets.

@CAYdenberg
Created April 6, 2016 19:15
Show Gist options
  • Save CAYdenberg/63d310fcf39b8fdcd48eebbdb2919fdd to your computer and use it in GitHub Desktop.
Save CAYdenberg/63d310fcf39b8fdcd48eebbdb2919fdd to your computer and use it in GitHub Desktop.
Fibonacci function in clojure
(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