in reply to Re: Behold! The power of recursion.
in thread Behold! The power of recursion.
"It is worth noting that while an iterative solution will almost inevitably run faster than a recursive solution, a good recursive solution is often quite terse."
Fully agree. Although this demos recursion, it is not a good example to demo the NEED of recursion.
A typical situation where recursion becomes a clearer solution is that, you need complex stack data structure to remember things otherwise, which is not the case here.
"A classic very simple example is the calculation of factorial n!"
My favorite is Hanoi Tower problem.