I am to calculate the amount of combinations of a number (let's call it C) using N numbers given.
I am to use a recursive formula.
However there is an error:
"TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType' "
My code:
def amount(N, C, latest_nominal = 0):
if C < 0:
return print("C should be positive")
if C == 0:
return print("1")
if not N:
return print("There are no nominals")
possibilities = 0
for nominal in N:
if nominal >= latest_nominal:
possibilities += amount(N, C-nominal, nominal)
return possibilities
I would appreciate any help! :)