Problem is you have to worry and take special care of infinite loop of recursive function.
And of course your solution is valid but not universal. Everytime you have to think of its minimal condition where it may not work. This solution gaureente that you simply put this condition and apply your logic, here you never meet infinite loop condition.
> Problem is you have to worry and take special care of infinite loop of recursive function.
Not really. It's too easy to do right.
> And of course your solution is valid but not universal.
It is both valid and universal -- it doesn't require the static variable your method requires, which is a bad idea, and it doesn't require mutable variables, which are disallowed in functional languages.
> Everytime you have to think of its minimal condition where it may not work.
It always works. Always. It never fails. Never.
> This solution gaureente that you simply put this condition and apply your logic, here you never meet infinite loop condition.
1. A recursion is not a "loop", infinite or otherwise.
2. Frankly, your solution is designed badly -- it requires a static variable, which prevents it from working in a case where this syntax is disallowed. It also requires the use of mutable variables, which are disallowed in functional languages.
> One of the biggest problem which developer are facing is breaking recursive function.
Not really any kind of problem.
> It is very hard and tricky to impose limit on recursive loop.
It is very easy. Not tricky at all. An easier way than yours: