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
Sample Output
Author
JGShining(极光炫影)
#include<iostream>
#include<string.h>
using namespace std;
int a[100000];
int main()int
{
int i,j;
int n;
while(cin>>n)
{
memset(a,0,sizeof(a));
a[0]=1;
int s,count=1;
for(i=1;i<=n;i++)
{
s=0;
for(j=0;j<count;j++)
{
a[j]=a[j]*i+s;
s=a[j]/10;
a[j]=a[j]%10;
}
while(s)
{
a[count]=s%10;
s=s/10;
count++;
}
}
for(i=count-1;i>=0;i--)
cout<<a[i];
cout<<endl;
}
return 0;
}