I was trying to solve that problem on csesCounting towers I wrote that snippet for it and it is failing. I do want to know why thank you in advance. *Note I have not added memoization to it.
def fn(x):
if x==1:
return 2
if x==2:
return 8
opt=0
for k in range(1,x):
if x-k >=0 and k>0:
opt+=(((fn(k)*fn(x-k))-1))
return opt+1