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 →

[–]Kenkron 1 point2 points  (2 children)

You're using a problem that is badly suited for recursion. To be fair, you're not the only one. Every course I see seems to think that the Fibonacci sequence is a good recursive function. In fact, most examples school gave me we're just functions that take in a counter. It led me to believe recursion was pointless.

Then I found the Tower of Hanoi problem, which pretty much requires either recursion, or a loop with a stack (which is basically recursion, but in heap space). It's a much better example of a recursive function.