Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@podviaznikov
Created October 30, 2013 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podviaznikov/7236147 to your computer and use it in GitHub Desktop.
Save podviaznikov/7236147 to your computer and use it in GitHub Desktop.
Fibonacci implementation on Clojure.
(defn fib-iter [a b n]
(if (zero? n)
b
(recur (+ a b) a (dec n))))
(defn fib [n]
(fib-iter 1 0 n))
(fib 40) ;102334155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment