Doubt in my code

I am not getting expected output what is the problem in my code ?

Hello @yashsharma4304 the mistake is that you are printing the actual result as well.
your code is giving this ouput:

1 Like

Ok I see that the mistake is present in base case. Thanks a lot :grinning:

check this:


commented the mistake:

1 Like

Ok now I understand.

@yashsharma4304 if you feel that your doubt is cleared you can mark this doubt as resolved.
Happy Learning!!

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like