+ 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
16 Réponses
+ 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
+ 6
MD AMAN ,
maybe this can help you:
https://www.geeksforgeeks.org/check-if-a-given-number-is-factorial-of-any-number/
+ 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.
+ 4
MD AMAN ,
What do you mean by reverse the code??
+ 3
You're welcome...
+ 3
MD AMAN you're welcome:-)
+ 2
What do you mean by "factorial value is true means ? "
Can you add an example?
+ 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.
+ 2
Thank you all for your efforts in solving this question
+ 1
Jayakrishna 🇮🇳
Can you explain in python how to reverse the code
+ 1
Jayakrishna 🇮🇳
sorry bro i didn't understand but got it now
And thanks
+ 1
Riya
Thankyou Riya for giving me answer now I can modify it and find answer with factorial no.
0
Riya
Jai Krishna was saying reverse the code, I was not saying
0
Lothar
Error occuring