Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (def memo-fib
- (memoize
- #(if (< % 2)
- 1
- (+ (memo-fib (dec %)) (memo-fib (- % 2))))))
- ; "dynamic programming step" (necessary to avoid stack overflow)
- (doseq [i (range 1 1000)] (memo-fib i))
- (time (println (memo-fib 1000)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement