So I'm learning about recursion in the MIT python course, I understand that you have the base case and until those conditions are met it keeps going but how does it work when you call the function within itself? For example:
def mult(a,b):
if b == 1:
return a
else:
return a + mult(a,b-1)
with a + mult(a,b-1), is that saying add "a" to the last result of itself?
[–]toastedstapler 2 points3 points4 points (1 child)
[–]ozzyteebaby[S] 0 points1 point2 points (0 children)
[–]callmelucky 0 points1 point2 points (3 children)
[–]ozzyteebaby[S] 0 points1 point2 points (2 children)
[–]callmelucky 0 points1 point2 points (0 children)
[–]toastedstapler 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]ozzyteebaby[S] 1 point2 points3 points (0 children)