Q. Write a Python function to calculate the factorial of a number (a non-negative integer). The function accepts the number whose factorial is to be calculated as the argument.
Answer =
def fact (n) :
if n== term +1 :
return 1
else :
return n*fact(n+1)
term = int(input("Enter the term :-"))
print("Factorial =",fact(1))
Output:-
Enter the term :-6
Factorial = 720
>>>
Factorial = 720
>>>
Enter the term :-12
Factorial = 479001600
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )