I want to prove that, $$ \log n! \in O(n \log n) \land \log n! \in \Omega(n \log n)$$ The straightforward approach is to apply Stirling's formula but I am looking for a different path to follow.
Can somebody please guide me towards it?
I want to prove that, $$ \log n! \in O(n \log n) \land \log n! \in \Omega(n \log n)$$ The straightforward approach is to apply Stirling's formula but I am looking for a different path to follow.
Can somebody please guide me towards it?
Note that $\log n! = \sum_{k = 1}^n \log k$. Then $$\sum_{k = 1}^n \log k = \int_1^{n + 1} \log \lfloor x \rfloor dx \le \int_1^{n + 1} \log x dx = (n + 1) \log (n + 1) - n,$$ and $$\sum_{k = 1}^n \log k = \int_0^{n} \log \lceil x \rceil dx \ge \int_0^{n} \log x dx = n \log n - n .$$
A nice method is : $$ \begin{align*} \log n! & = \log \prod_{\psi=1}^n \psi \\ & = \sum_{\psi=1}^n \log \psi \\ & \sim \int_1^n \log \psi \; \mathrm d \psi \\ & = \psi \log \psi - \psi \Biggr|_{1}^{n} \\ & = n \log n - (n - 1) \end{align*} $$ If we had used stirling's approximation instead, we would have received $$ \log n! = n \log n - n + \Theta(\log n) $$ Alternate methods involve
As far as I see, the solutions have all used integration. We can easily do without. Of course $\log n! = \sum_{k=1}^n \log k$.
For the upper bound use $\log k \le \log n$ for $1\le k \le n$, so $\sum_{k=1}^n \log k \le \sum_{k=1}^n \log n =n \log n$.
For the lower bound, observe that $\log \frac n2 \ge \frac 12{\log n}$ for $n\ge 4$. Thus $\sum_{k=1}^n \log k \ge \sum_{k={\frac n2}}^{n} \log k \ge \frac n2 \log \frac n2 \ge \frac n4 \log n$.
For complete rigor,
$$x-1\le\lfloor x\rfloor\le x$$
so that by monotonicity of the logartihm
$$\log(x-1)\le\log\lfloor x\rfloor\le \log x.$$
Hence by integration from $2$ to $n+1$,
$$\int_1^n\log x\,dx\le\sum_{k=2}^n\log k\le\int_2^{n+1}\log x\,dx$$
and
$$n\log n-n+1\le\log n!\le(n+1)\log(n+1)-n+1-2\log2.$$
Without any hard maths: log n! = log 1 + log 2 + log 3 + … + log n. We are adding n numbers, each at most log n, so the sum is at most n log n.
On the other hand, log ( sqrt (n)) = (log n) / 2, so all but sqrt(n) of the numbers we are adding are at least (log n) / 2, giving a lower bound. For n>= 4, sqrt(n) <= n/2 so we are adding at least n/2 numbers, each at least (log n) / 2, for a total of (n log n) / 4.