Problem in code

my code is getting into an infinite loop… i am unable to identify why. It is working if i use exit statement in the base case.
please help.


added two return statements