C 数组模拟阶乘运算

时间:2024-09-29 15:03:44
#include <stdio.h>

void rdump(int arr[],int len)
{
int i = ;
for(i=len-;i >= ; --i)
{
printf("%d",arr[i]);
}
printf("\n");
} void trailingZeroes(int n) {
int arr[] = {},len = ,i = ,j = ,c = ,d = ;
for(i=; i <= n; ++i)
{
for(j = ; j < len; ++j)
{
d = arr[j] * i + c;
arr[j] = d % ;
c = d / ;
}
for(; c > ; c /= )
{
arr[len++] = c % ;
}
}
rdump(arr,len);
} int main()
{
int n = ;
while()
{
scanf("%d",&n);
trailingZeroes(n);
}
return ;
}

相关文章