Re:Thinking About Recursion
by tgv on Sunday October 11, 2020 @12:59PM
(#24747210)
The recursive version of Fibonacci is generally not tail recursive, but f(n) = f(n - 1) + f(n - 2).
[ Parent
| on HN ]
It's easy enough to convert by adding arguments for the two variables used in the iterative version:
The point of recursion is not recursion, but a better way to write code. Better can be more readable, less errors, whatever, but adding two parameters to the Fibonacci function for the sake of introducing tail recursion, where even iteration is more understandable, is pointless.