How to find factorial bounds for a power of 2 quantity

619 Views Asked by At

I'm trying to find the integer $n$ such that

$$ n! \leq 2^k-1 \leq (n+1)! $$

In particular for $k = 19937$

Wolfram Alpha choked on it, but I've got a feeling there is a trick somewhere to compute this.

1

There are 1 best solutions below

0
On BEST ANSWER

You just need a reasonable bound for $\log(n!)$, and by Stirling's inequality $$ n\log n-n+\frac{1}{2}\log(2\pi n)+\frac{1}{12n+1}\leq\log(n!) \leq n\log n-n+\frac{1}{2}\log(2\pi n)+\frac{1}{12n} $$ so it is enough to solve $$ \left(n+\frac{1}{2}\right)\log n-n = k\log2-\log\sqrt{2\pi} $$ through Newton's method with starting point $n_0=\frac{k\log 2}{\log k}$.
If $k=19937$, with just a couple of iterations we get $n=2080$.