/*
N!
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 67077 Accepted Submission(s): 19228
Problem Description
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
Input
One N in one line, process to the end of file.
Output
For each N, output N! in one line.
Sample Input
1
2
3
Sample Output
1
2
6
Author
JGShining(极光炫影)
Recommend
We have carefully selected several similar problems for you: 1715 1063 1753 1316 1013
*/
#include <iostream>
#include<stdio.h>
using namespace std;
const int Len = 40000;
int *a =new int[Len];
int main()
{
int i,j,n,pos,over;
//double test;
while(scanf("%d",&n)!=EOF)
{
//test=1;
pos=0;
a[0]=1;
for(i=1; i<=n; i++)
{
over=0;
for(j=0; j<=pos; j++)
{
a[j]*=i;
a[j]+=over;
over=a[j]/100000;//each five bit calculate
a[j]%=100000;
}
if(over!=0)
{
pos+=1;
a[pos]=over;
}
}
printf("%d",a[pos]);//high-five-bit output-length follow its length
for(i=pos-1; i>=0; i--)
{
printf("%05d",a[i]);//others output-length must be five
}
printf("\n");
//for(i=1;i<=n;i++)
//test*=i;
//printf("%f\n",test);
}
return 0;
}