+ 1

How to find factorial of a given number using python

16th Nov 2022, 6:25 AM
yash maisuriya
yash maisuriya - avatar
5 Respostas
+ 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)
25th Nov 2022, 4:07 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
Please attempt the code firstly and then if you get any error we will help you.
16th Nov 2022, 6:36 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 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)
24th Nov 2022, 7:40 PM
yash maisuriya
yash maisuriya - avatar
+ 1
I attempted this code and its give me output
24th Nov 2022, 7:40 PM
yash maisuriya
yash maisuriya - avatar
+ 1
Okk ma'am I will... Thank you for your guidance
25th Nov 2022, 4:25 AM
yash maisuriya
yash maisuriya - avatar