简体   繁体   中英

Prove that n! = O(n^n)

How can I prove that n! = O(n^n)?

I assume that you want to prove that the function n! is an element of the set O(n^n) . This can be proven quite easily:

Definition: A function f(n) is element of the set O(g(n)) if there exists a c>0 such that there exists a m such that for all k>m we have that f(k)<=c*g(k) .

So, we have to compare n! against n^n . Let's write them one under another:

n!  = n * (n-1) * (n-2) * (n-3) * ... * 3 * 2 * 1
n^n = n *  n    *  n    *  n    * ... * n * n * n

As you can see, the first line ( n! ) and the second line ( n^n ) have both exactly n items on the right side. If we compare these items, we see that every item is at most as large as it's corresponding item in the second line. Thus n! <= n^n n! <= n^n .

So, we can - look at the definition - say, that there exists c=1 such that there exists m=5 such that for all k>5 we have that k! < k^k k! < k^k , which proves that n! is indeed an element of O(n^n) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM