+ 1
How to find factorial of a given number using python
5 Answers
+ 1
Your code is right but I think you want to print like this:-
def fact (n):
if (n==1):
return 1
else:
return n*fact(n-1)
x=int(input())
f=fact(x)
print("factorial of",x,"is:- ",f)
+ 1
Please attempt the code firstly and then if you get any error we will help you.
+ 1
def fact (n):
if (n==1):
return 1
else:
return n*fact(n-1)
x=int(input("enter number:"))
f=fact(x)
print(f)
+ 1
I attempted this code and its give me output
+ 1
Okk ma'am I will... Thank you for your guidance