挑战 你能用C语言写出比这更短的阶乘函数吗
c吧
全部回复
仅看楼主
吧务
level 10
BestAns 楼主
int fact(int n) { for (int i = 1; n > 1; n--) i *= n; return i; }
2024年11月24日 09点11分 1
吧务
level 10
BestAns 楼主

int fact(int n) {return n > 1 ? n * fact(n - 1) : 1;}
2024年11月25日 04点11分 3
1