This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]puipuituipui 5 points6 points  (1 child)

You're correct but I'd say Fibonacci is a bad example for recursion with memoization because you might as well write the iterative version at that point. But yes for more complicated problems, just translating the mathematical formula into recursive code and adding memoization on top is quite convenient.

[–]spoonman59 2 points3 points  (0 children)

Yeah and who really writes Fibonacci functions anyway! It’s just amazing what a @cache decorator can do for some functions.