How to find factorial of a given number using python | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

How to find factorial of a given number using python

16th Nov 2022, 6:25 AM
yash maisuriya
yash maisuriya - avatar
5 Réponses
+ 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
Sakshi - 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
Sakshi - 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