简体   繁体   English

证明 n! = O(n^n)

[英]Prove that n! = O(n^n)

How can I prove that n!我如何证明 n! = O(n^n)? = O(n^n)?

I assume that you want to prove that the function n!我假设你想证明函数n! is an element of the set O(n^n) .是集合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) .定义:函数f(n)是集合O(g(n))的元素,如果存在c>0使得存在m使得对于所有k>m我们有f(k)<=c*g(k)

So, we have to compare n!所以,我们必须比较n! against n^n .反对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.如您所见,第一行 ( n! ) 和第二行 ( n^n ) 在右侧都有n项目。 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 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所以,我们可以 - 查看定义 - 说,存在c=1使得存在m=5使得对于所有k>5我们有那个k! < k^k k! < k^k , which proves that n! k! < k^k ,这证明了n! is indeed an element of O(n^n) .确实是O(n^n)的一个元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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