Reputation: 33
I was wondering if log(n!) is O(n), or if n is O(log(n!)). I have seen that log(n!) is O(n log(n)) but there is no information that I can find available to my particular question.
Upvotes: 2
Views: 138
Reputation: 58613
Stirling's approximation implies that log(n!) = Θ(n log(n))
. In particular, it is not true that log(n!) = O(n)
, and it is true that n = O(log(n!))
.
Upvotes: 2
Reputation: 2546
Log(n!) grows much faster as compared to n.
You can see from the picture.
Example :
When n =50,
O(n) will be 50.
But, O(log(n!)) = 64.48.
Update :
I tried plotting n and log(n!), on the same Graph.
log(n!) = O(n) for 0 < n < 25
n = O(log(n!)) for n > 25
Upvotes: 1