Skip to content

Instantly share code, notes, and snippets.

@perezd
Created January 29, 2012 21:14
Show Gist options
  • Save perezd/1700690 to your computer and use it in GitHub Desktop.
Save perezd/1700690 to your computer and use it in GitHub Desktop.
; iterative fibonacci technique,
; in clojure.
(defn fib-step [[a,b]]
[b (+ a b)]
)
(defn fib-seq []
(map first (iterate fib-step [0 1]))
)
(defn fib [n]
(nth (fib-seq) n)
)
; usage
(fib 2000)
; => 422469633339230487870...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment