#include<stdio.h>
#include<math.h>
int main()
{
int n;
int sum = 1;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
sum *= i;
}
printf("%d", sum);
return 0;
} //非递归
#include<stdio.h>
int floor(int n)
{
if (n == 1)
{
return 1;
}
else
{
return floor(n-1)*n;
}
}
int main()
{
int n;
int ret;
scanf("%d", &n);
ret = floor(n);
printf("%d", ret);
return 0;
}
原文地址:https://blog.51cto.com/14737345/2479827
时间: 2024-11-08 16:57:41