+ 2

Can anyone tell me how to check the value of factorial in python program?

I writed a programe to find factorial value .but I want to write another program tocheck the value of factorial.if factorial value is true then find factorial no.else print these are not factorial value?? Anyone help me? https://code.sololearn.com/c3lIkXDumlOG/?ref=app

31st Aug 2023, 2:15 PM
MD AMAN
MD AMAN - avatar
16 Respostas
+ 7
MD AMAN , What Jayakrishna 🇮🇳 bro meant is, You have to take a number as a input for example 120 ... and if the number is factorial means first that number (120) should be divisible by 2 and the quotient is (60) Then take that quotient (60) that should be divisible by 3 and now the new quotient is (20) Then take this new quotient (20) That should be divisible by 4 and now the new quotient is (5) Then take the this new quotient (5) That should be divisible by 5 and the quotient you get is (1) For whatever number you take as input....if you get (1) as a quotient at last then it is factorial... otherwise it is not factorial.... This is what he said reverse ...that means from 120 to 5 you are going reverse.... And the divisor you are increasing from 2 to 5 Here the code, as giving ready-made solution is not a practice here as you couldn't understand....so iam providing you the code....go through it.... https://code.sololearn.com/cWVZO2643mLZ/?ref=app
31st Aug 2023, 5:05 PM
Riya
Riya - avatar
31st Aug 2023, 2:46 PM
Lothar
Lothar - avatar
+ 5
MD AMAN , i am sure that the given code from the link is working if it is copied / pasted properly, but this is not the purpose of the link. it has a short description how the task could be done. regardless of the solution shown, there is another way: we can do exactly the same procedure as if we are creating a factorial: > run a loop that is doing one multiplication in each loop iteration. we need to increment the number in each loop iteration. > check if the result of the current multiplication is equal to the input number. if yes: the input number was built as a factorial. then output the message and break the loop. > check if the result of the current multiplication is greater than the input number. if yes: the input number was NOT built as a factorial.
31st Aug 2023, 3:45 PM
Lothar
Lothar - avatar
+ 4
MD AMAN , What do you mean by reverse the code??
31st Aug 2023, 3:33 PM
Riya
Riya - avatar
+ 3
MD AMAN i mean reverse the process. Not the code. And i already explained an example. Now Riya as well.. with code. hope those enough.!
31st Aug 2023, 5:14 PM
Jayakrishna 🇮🇳
+ 3
You're welcome...
31st Aug 2023, 6:00 PM
Jayakrishna 🇮🇳
+ 3
MD AMAN you're welcome:-)
31st Aug 2023, 6:31 PM
Riya
Riya - avatar
+ 2
What do you mean by "factorial value is true means ? " Can you add an example?
31st Aug 2023, 2:41 PM
Jayakrishna 🇮🇳
+ 2
For factorial 5 , you do like 2*3*4*5=120 For example 120 is a factorial of any number then do it reverse like 120/2 = 60 60/3 = 20 20/4=5 5/5 = 1 Loop until, you get num > 1 , and final result you get will be 1.0 for true factorial, else any other value.
31st Aug 2023, 2:52 PM
Jayakrishna 🇮🇳
+ 2
Thank you all for your efforts in solving this question
31st Aug 2023, 6:04 PM
MD AMAN
MD AMAN - avatar
+ 1
Jayakrishna 🇮🇳 Can you explain in python how to reverse the code
31st Aug 2023, 3:20 PM
MD AMAN
MD AMAN - avatar
+ 1
Jayakrishna 🇮🇳 sorry bro i didn't understand but got it now And thanks
31st Aug 2023, 5:57 PM
MD AMAN
MD AMAN - avatar
+ 1
Riya Thankyou Riya for giving me answer now I can modify it and find answer with factorial no.
31st Aug 2023, 5:59 PM
MD AMAN
MD AMAN - avatar
0
Lothar Code doesn't work in python program
31st Aug 2023, 3:21 PM
MD AMAN
MD AMAN - avatar
0
Riya Jai Krishna was saying reverse the code, I was not saying
31st Aug 2023, 4:33 PM
MD AMAN
MD AMAN - avatar
0
Lothar Error occuring
31st Aug 2023, 4:34 PM
MD AMAN
MD AMAN - avatar