如题所述
#include <stdio.h>
int factorial(int n) {
if(n <= 1) { // 0! = 1, 1! = 1
return 1;
} else {
return n * factorial(n - 1);
}
}
int main() {
/* 计算 5阶乘 + 8阶乘 */
int result = factorial(5) + factorial(8);
printf("%d\n", result);
return 0;
}
温馨提示:答案为网友推荐,仅供参考