I am getting WA for 2 subtasks in this question : https://www.codechef.com/problems/KFIB

My solution : https://www.codechef.com/viewsolution/18321444

Could someone please point out my mistake ?

Yes, it helped. The formula wasn't totally wrong. I had to add another case. Thank you.

preda2or23:33, Apr 20Shubham Kumar GuptaThe formula you are using to find the next term (i.e 2*a[i-1] -1) isn't correct .

Try this test case:

Your output: 9

Correct output: 8

Hope it helps :)

Please make sure the answer is not too short