While solving the complexity of a code, I found it as O(log(n!)). I know that this can be proven equal to O(n*log(n)). However, can someone tell where this proof is going wrong?
Theorems used:
- log(ab) = log(a) + log(b)
- O(a+b) = O(max(a,b))
Proof
O(log(n!)) = O(log(n*(n-1)*(n-2)*...*2*1))
= O(log(n) + log(n-1) + ... )
= O(max(logn, log(n-1), ...))
= O(log(n))
Can someone tell where I'm going wrong?