[英]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.