代码如下:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
void factorial(int n) ;
int n;
cin>>n;
factorial(n);
return 0;
}
void factorial(int n)    
{    
            long a[10000];    
            int i,j,l,c,m=0,w;    
            a[0]=1;    
            for(i=1;i<=n;i++)    
            {    
                     c=0;    
                     for(j=0;j<=m;j++)    
                     {    
                                 a[j]=a[j]*i+c;    
                                 c=a[j]/10000;    
                                 a[j]=a[j]%10000;    
                     }    
                     if(c>0)    
                     {    
                                 m++;    
                                 a[m]=c;    
                     }    
            }
            cout<<a[m];
            for(i=m-1;i>=0;i--)    
                 cout<<a[i];    
            cout<<endl;
}