Show log(n!) = Theta(n log n) via Stirling
Analyze the show log(n!) = theta(n log n) via stirling.
Examples
Input: "test_input_1"
Output: "output_1"
Input: "test_input_2"
Output: "output_2"
Hints
Recall Stirling's approximation formula for factorials: n! ≈ √(2πn) (n/e)^n, and use it to express log(n!) in terms of n.
Expand log(n!) using the approximation: log(n!) ≈ n log n - n + (1/2)log(2πn) + O(1/n), then analyze the dominant terms as n → ∞.
Prove the upper and lower bounds separately: Show log(n!) ≤ n log n + O(n) and log(n!) ≥ n log n - O(n), then combine them to conclude log(n!) = Θ(n log n).
Show log(n!) = Theta(n log n) via Stirling
Analyze the show log(n!) = theta(n log n) via stirling.