Fails when n>=10

the code works fine till n = 9, but after that it always gives a result less than actual number of solutions. I can’t find what is wrong with the logic. please help /\