I’m getting this error:
TypeError: unsupported operand type(s) for +: ‘int’ and ‘NoneType’
For this code:
def a(n):
if n < 0:
return 0
if n == 1:
return 1
if n > 1:
return a(n-1) + a(n-2) + a(n-3)
How should I call multiple recursions?
You are missing the condition: –
1 > n >= 0. And thus, you are not returning any value in case yourn >= 0andn < 1.May be your first condition is supposed to be: –