这是我的递归尝试。它编译并运行,但不显示我输入的数字的阶乘。我在 Ubuntu 上用 Geany 尝试这个。
#include <stdio.h>
int fact(int n);
int main() {
int n;
printf("Give me a number");
scanf("%6d", &n);
fact(n);
}
int fact(int n) {
if (n <= 1)
return 1;
else
return n * fact(n - 1);
}