本文介绍了递推关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么递归阶乘算法这样的递推关系?
Why is the recurrence relation of recursive factorial algorithm this?
T(n)=1 for n=0
T(n)=1+T(n-1) for n>0
为什么不呢?
Why is it not this?
T(n)=1 for n=0
T(n)=n*T(n-1) for n>0
ñ即1,2,3,4把价值观......第二递推关系持有(该阶乘计算正确无误)不是第一个。
Putting values of n i.e 1,2,3,4...... the second recurrence relation holds(The factorials are correctly calculated) not the first one.
请清除我的疑问。
推荐答案
这个问题很困惑......你第一个公式是不是阶乘。这只不过是T(N)= N + 1,对于所有的n。 n个阶乘是第n个正整数的乘积:阶乘(1)= 1阶乘(N)= N *阶乘(N-1)。你的第二个公式是基本上是正确的。
This question is very confusing... You first formula is not factorial. It is simply T(n) = n + 1, for all n. Factorial of n is the product of the first n positive integers: factorial(1) = 1. factorial(n) = n * factorial(n-1). Your second formula is essentially correct.
这篇关于递推关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!