Type conversion and generating big Fibonacci numbers in Clojure

less than 1 minute read

Notes

;; bigger_fibonacci.clj

(def fib (memoize
          (fn [index]
            (case index
              1 0
              2 1
              (+
               (bigint (fib (dec index)))
               (bigint (fib (- index 2))))))))
;; 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: