给出一个数字N,求出其N!,,N在10000以内。
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#include<math.h>
using namespace std;
int go[19000];
int n ;
int main()
{
int i,j,k;
while (cin>>n)
{
if (n==0||n==1)
cout<<'1'<<endl;
else
{
memset(go,0,sizeof(go));
int l=1;
go[0]=1;
for (i=2;i<=n;i++)
{
for (j=0;j<l;j++)
{
go[j]=go[j]*i;
}
for (j=0;j<l;j++)
{
if (go[j]>=10000)
{
go[j+1]=go[j]/10000+go[j+1];
go[j]=go[j]%10000;
if (j==l-1)
l++;
}
}
}
cout<<go[l-1];
for (i=l-2;i>=0;i--)
{
if (go[i]<10)
cout<<"000";
else if (go[i]<100)
cout<<"00";
else if (go[i]<1000)
cout<<"0";
cout<<go[i];
}
cout<<endl;
}
}
}