对下面两个函数,说法错误的是( )。
int factorialA(int n) {
if (n <= 1) return 1;
return n * factorialA(n-1);
}
int factorialB(int n) {
if (n <= 1) return 1;
int res = 1;
for(int i=2; i<=n; i++)
res *= i;
}
- A. 两个函数的实现的功能相同。
- B. 两个函数的时间复杂度均为 。
- C. factorialA采用递归方式。
- D. factorialB采用递归方式。
正确答案:D