Class Assignment - Hackerblocks

https://ide.codingblocks.com/s/61546

https://hack.codingblocks.com/contests/c/537/875

Even though I understand the problem is given for recursion but I have tried a different approach using set bits.
Instead of looking at the combinations in question as that of ‘a’ and ‘b’ , if we look at them as ‘a’ as 0 and ‘b’ as 1 then we only have to count the number of numbers < (2^n) having no consecutive set bits. This is my approach. Please tell if my approach is wrong and if not then point out the problem with my code please.

Hi Tarun, your approach is working fine till 2^15. But your code is not giving correct output for greater values of n like 35, 40 etc.