I've seen some other similar topics, but I can't apply the solutions to fix the error given by the following code:
if b == 1:
return a + mult_recursive(a,b-1)
if n == 0:
elif n == 1:
You get that error because you've exceeded maximum recursion depth. What exactly you misunderstand? Go line by line and calculate the depth of calls you make. If you exceed max recursion depth, you're done. It seems that for
n==8 you exceed it. For lowers you don't.
And that makes sense, since for
n==8 you have
factorial_recursive(n-1) == 5040 and thus
mult_recursive(n, factorial_recursive(n-1)) does
5040 nested calls. This is definitely too much.
n == 7 you only do
720 nested calls. By default max recursion is
1000 (might depend on your machine/python version) so there you go.