1
The function, when undoes recursion, returns None
, and I don’t know why.
def fat(n):
if n == 0 or n == 1:
return 1
else:
return n * fat(n - 1)
def superfat (n, x = 1):
if n > 0:
x*=fat(n)
n-=1
return superfat(n, x)
número = int(input("Digite um número para descobrir o seu superfatorial: "))
print("O fatorial de {} é {}.".format(número, superfat(número)))
In function
superfat
, will reach the point wheren
will be 0. What value should be returned in this case? As you did not put, it will beNone
.– Woss