can someone explain what's wrong with the below code?
def factorial(num):
if num == 0 or 1:
return 1
else:
result = num * factorial(num-1)
return result
#print(factorial(30))
#output: 1
& on the contrary when the if statement is slightly modified as below. The code seems to do what its meant to do. I would appreciate if someone could comment on why the code below provides desired output while the code above doesn't
def factorial(num):
if num == 1 or 0:
return 1
else:
result = num * factorial(num-1)
return result
#print(factorial(30))
#265252859812191058636308480000000