Why would LeetCode request self.functionName() in recursive functions?

I am new to LC, so this question might be already asked. If so, please share link to the discussion.

I wrote a recursive function to solve one of the easy problems, however, unless I use self.functionName() within the upper level function my solution doesn't work and I don't understand why LC requres self in front of function name.

Here is the code:

    def numberOfMatches(self, n: int) -> int:
        matches = 0
        if n % 2 == 0:
            pass
            return matches + self.numberOfMatches(n / 2)
        elif n >= 2:
            pass
            return matches + self.numberOfMatches((n - 1) / 2 + 1)
        return matches

Please note that the code will not work, I just changed it to not spoil the solution.

Comments (1)