programming-examples/python/Function/Python function to calculate the factorial of a number (a non-negative integer).py

7 lines
191 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
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))