Number of bits to write $n!$

157 Views Asked by At

How many bits, as a function of $n$, are required to write the number $n!$ in binary? The function of $n$ needs to be in $\Theta(·)$ (Big-Theta) form.

I understand that to write a number in binary, you need $\log(n)+1$ (not sure how to write ceiling function in SE) bits.

1

There are 1 best solutions below

0
On

Hint:

$$\log x\le\log\lfloor x\rfloor\le\log(x+1)$$ so that by integration

$$\int_1^{n+1}\log x<\int_1^{n+1}\log\lfloor x\rfloor=\sum_{k=1}^n\log k<\int_1^{n+1}\log(x+1).$$

Hence

$$((n+1)\log(n+1)-1)+1<\log n!<(n+2)\log(n+2)-n-\log 4.$$