Fibonacci properly memoized in Clojure

less than 1 minute read

Notes

;; memonize_fib_right_way.clj

(def fib (memoize
          (fn [index]
            (case index
              1 0
              2 1
              (+
               (fib (dec index))
               (fib (- index 2)))))))
(fib 52)

Updated: