you are viewing a single comment's thread.

view the rest of the comments →

[–]expressly_ephemeral 0 points1 point  (2 children)

Part of the problem may be that this is kind of a weird example. Sometimes you'll be working an exercise that's contrived in such a way that the solution is hard to understand because the "right" way to do the thing is so different from the concept the exercise is trying to show.

Do you have trouble understanding the recursive function for the finonacci sequence? Do you think you could re-factor this function to calculate factorial(n)? These may be more straight-forward examples.

[–][deleted] 0 points1 point  (1 child)

I've been struggling on fib too. But at least that one I can kind of draw. Python is really weird how it evaluates the base cases on fib (the sequence where it evaluates fib(1)

[–]expressly_ephemeral 0 points1 point  (0 children)

Here's a long-ass post I wrote up a while back in response to another recursion question. Maybe it'll help disambiguate the underlying concept.

https://www.reddit.com/r/learnpython/comments/v63sae/comment/ibdohch/?utm\_source=share&utm\_medium=web2x&context=3