Well, we all know that if N is given it\'s easy to calculate N!. But what about the inverse?
N! is given and you are about to find N - Is that possible ? I\'m curio
X=1
.F=X!
X
is N.X=X+1
, then start again at #2.You can optimize by using the previous result of F
to compute the new F
(new F = new X * old F
).
It's just as fast as going the opposite direction, if not faster, given that division generally takes longer than multiplication. A given factorial A!
is guaranteed to have all integers less than A
as factors in addition to A, so you'd spend just as much time factoring those out as you would just computing a running factorial.