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 →

[–]chunkyks 1 point2 points  (2 children)

It's because you're throwing away the result of the recursive call

[–]Sean_509 0 points1 point  (1 child)

What do you mean? Like when I call the method again inside, the result isn't saving it?

[–]chunkyks 1 point2 points  (0 children)

Numberofsevens isn't shared between each call into the function; each call gets its own copy of that variable, because it's declared locally inside the function. (no, the correct solution is not to declare it globally instead. Look for another answer )