对下面两个函数,说法错误的是( )。
1 int factorialA(int n) { 2 if (n <= 1) return 1; 3 return n * factorialA(n-1); 4 } 5 int factorialB(int n) { 6 if (n <= 1) return 1; 7 int res = 1; 8 for(int i=2; i<=n; i++) 9 res *= n; 10 }
两个函数的实现的功能相同。
两个函数的时间复杂度均为O(n)。
factorialA采用递归方式。
factorialB采用递归方式。