1
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.