[Math] Inverse of a factorial

factorial

I'm trying to solve hard combinatorics that involve complicated factorials with large values.

In a simple case such as $8Pr = 336$, find the value of $r$, it is easy to say it equals to this: $$\frac{8!}{(8-r)!} = 336.$$

Then $(8-r)! = 336$ and by inspection, clearly $8-r = 5$ and $r = 3$.

Now this is all and good and I know an inverse function to a factorial doesn't exist as there is for functions like sin, cos and tan etc. but how would you possibly solve an equation that involves very large values compared to the above problem without the tedious guess and checking for right values.

Edit: For e.g. if you wanted to calculate a problem like this (it's simple I know but a good starting out problem)
Let's say 10 colored marbles are placed in a row, what is the minimum number of colors needed to guarantee at least $10000$ different patterns?
WITHOUT GUESS AND CHECKING

Any method or explanation is appreciated!

Best Answer

I just wrote this answer to an old question. Using $a=1$, we get a close inverse for the factorial function: $$ n\sim e\exp\left(\operatorname{W}\left(\frac1{e}\log\left(\frac{n!}{\sqrt{2\pi}}\right)\right)\right)-\frac12\tag{1} $$

Related Question