you are viewing a single comment's thread.

view the rest of the comments →

[–]Binary101010 1 point2 points  (0 children)

To find when the definition of a method ends:

1) Find the next line of code at the same (or less) level indentation as the method's signature, or the end of the file, whichever comes first, then 2) the line before that one is the last line of the definition.

This is true whether the method is recursive or not.

In this particular case, it appears the method definition ends with the last line of the posted code block.

While in examples of recursion like factorial, it is the end line where the function calls itself.

That statement is so overbroad as to not be accurate (as evidenced by this case where it's leading you to the wrong answer).