#include <iostream>
#include <cstdio>
using namespace std;
void factorial(int);
int main(void)
{
int number;
while(scanf("%d",&number)!=EOF){
factorial(number);
cout << endl;
}
return 0;
}
void factorial(int a)
{
int i,j;
int result[50000];
int count = 1;
int carry = 0;
int temp = 0;
result[1]=1;
for(i = 2; i <= a; i ++){
for(j = 1; j <=count; j ++){
temp = result[j] * i + carry;
result[j] = temp % 10000;
carry = (int)(temp / 10000);
}
while(carry){
count ++;
result[count] = (carry % 10000);
carry = (int)(carry / 10000);
}
}
cout << result[count];
for(i =count-1;i>=1; --i)
printf("%04d",result);
}
复制别人的././希望对你有用./
哦耶