我在Eclipse IDE中用Java实现了一个阶乘函数.
public class Utilities {
public static int factorial(int n) {
int result;
if (n <= 1) // base case
return 1;
else {
result = (n * factorial(n - 1));
return result;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在Eclipse的显示中,我检查Utilities.factorial(6).但是,我收到此错误.
Utilities.factorial(6);
Evaluation failed. Reason(s):
Cannot perform nested evaluations.
Run Code Online (Sandbox Code Playgroud)
为什么显示不支持递归调用?那是问题吗?
| 归档时间: |
|
| 查看次数: |
4858 次 |
| 最近记录: |