Skip to content

Instantly share code, notes, and snippets.

@RussellAndrewEdson
Created January 4, 2015 03:58
Show Gist options
  • Save RussellAndrewEdson/95c30531351204c5e957 to your computer and use it in GitHub Desktop.
Save RussellAndrewEdson/95c30531351204c5e957 to your computer and use it in GitHub Desktop.
Clojure code to generate the nth Fibonacci number iteratively.
(defn fibonacci
"Returns the nth Fibonacci number using an iterative process."
[n]
(loop [current 0N next 1N index 0]
(if (= index n)
current
(recur next (+ current next) (inc index)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment