Wrong Answer in 1 tc

Getting the Wrong Answer in the last test case. Please tell me what error is there in my code.
Thanks in advance.

Hello @sanjit_15 could you share the link for this question on hackerblocks so that i can check and try to submit it.

@sanjit_15 you can see this code:


if you have any doubt in this you can ask here:
Happy Learning!!

I got the recursive solution. But can you tell why the direct formula is failing 1 test case.?

Hello @sanjit_15 as the test cases are alarger so you need to store the result for the number so that it should not recalculate it for the already calculated part.
if you have any other doubt you can ask here:
Happy Learning!!

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.