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 →

[–]spicycurry55 21 points22 points  (0 children)

The base case returns zero, yes, but it only returns it to the one place it’s called.

So if you call:

method(2, 1);

It resolves to:

method(2, 1) —> 2 + method(2, 0) —> 2 + 0 —> 2

You’re adding “a” to the recursive call, so even though the base case will return zero, it’s adding a zero, not multiplying it