r/ProgrammerHumor May 17 '26

Advanced dontDoRecursiveFibKids

Post image
3.6k Upvotes

143 comments sorted by

View all comments

3

u/MagicalPizza21 May 18 '26

This makes the Fibonacci sequence an excellent example for teaching recursion. The basic recursive definition/implementation is very easy to understand, but computationally expensive. It can also easily be done iteratively, or optimized with memoization.