Write a Python function to calculate the factorial of a number (a non-negative integer)
def factorial(n):
if n==0:
return 1
else:
return n*factorial(n-1)
n=int(input("Input a number to compute the factiorial : "))
print(factorial(n))
#OUTPUT
#INPUT NUMBER : 3
#6
Comments
Post a Comment