Mar-15-2019, 12:11 AM
You're using recursion. When you have recursion, you have two situations: a "base case" (where you don't recurse) and a recursive case. The error you're encountering is incredibly common when the base case isn't solid. I suggest you not just use Yoriz' code, but rather you walk through your own code and then his in order to understand what's happening.
Also, this looks like homework, which often has weird requirements, but I wouldn't use recursion for what you're trying to do there.
Also, this looks like homework, which often has weird requirements, but I wouldn't use recursion for what you're trying to do there.