Q:

Write a Python function to calculate the factorial of a number

0

Write a Python function to calculate the factorial of a number

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used python 3.7 compiler for debugging purpose.

def factorial(num):
    if num == 0:
        return 1
    else:
        return num * factorial(num-1)
num=int(input("Input a number to compute the factiorial : "))
print(factorial(num))

Result:

Input a number to compute the factiorial : 5

120

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Python function to check whether a number ... >>
<< Write a Python function to reverse given string...