Skip to content

Instantly share code, notes, and snippets.

@sinanduman
Created October 7, 2015 17:48
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 sinanduman/67f663f203bc2c2cf5d3 to your computer and use it in GitHub Desktop.
Save sinanduman/67f663f203bc2c2cf5d3 to your computer and use it in GitHub Desktop.
Fibonacci numbers with tail recursion optimization
(defn fib
([n]
(fib n 0 1 0) )
([n start prev acc]
(if (= n start)
acc
(fib n (inc start) acc (+ prev acc ) )
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment