Skip to content

Instantly share code, notes, and snippets.

@melklein
Last active June 27, 2016 20:54
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 melklein/9bc192874dc3b8995a7a826d3dca935f to your computer and use it in GitHub Desktop.
Save melklein/9bc192874dc3b8995a7a826d3dca935f to your computer and use it in GitHub Desktop.
recursion in clojure with fibonacci numbers
(defn fib-anon [mx]
((fn [x result]
(if (= x 0)
(reverse result)
((let [next-fib (reduce + (take 2 result))]
recur (dec x) next-fib))))
(- mx 2) '(1 1)))
@melklein
Copy link
Author

first version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment