DEV Community

Discussion on: What is Recursion, and Why Shouldn't You Use It?

Collapse
 
lordnodd profile image
Ashwin

We use cache for such disadv, by storing pre-calculated fib(n) and checking if it exists, that way you avoid the hassle of calculating fib(1) 51 times.

Collapse
 
darthbob88 profile image
Raymond Price

Yeah, memoization. That's the second method I mentioned for mitigating the issues of recursion.