Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prove that n! = O(n^n)

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

like image 770
Wilbert Barrera Avatar asked Feb 15 '11 02:02

Wilbert Barrera


1 Answers

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.

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, which proves that n! is indeed an element of O(n^n).

like image 98
phimuemue Avatar answered Nov 03 '22 18:11

phimuemue