![](https://pic002.cnblogs.com/images/2012/428307/2012071912411683.jpg)
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <math.h>
4 int wei(int n)
5 {
6 int i;
7 double sum=0;
8 for(i=1;i<=n;i++) sum+=log10((double)i);
9 return (int)((sum+1)/4+1);
10 }
11 int main()
12 {
13 int i,j,n,jinwei,weishu=1,temp;
14 unsigned int *x;
15 scanf("%d",&n);
16 x=(unsigned int*) malloc(wei(n)*sizeof(int));
17 x[0]=1;
18 for(i=2;i<=n;i++)
19 {
20 jinwei=0;
21 for(j=1;j<=weishu;j++)
22 {
23 temp=x[j-1]*i+jinwei;
24 if (temp>=1)
25 {
26 x[j-1]=temp%10000;
27 jinwei=temp/10000;
28 }
29 }
30 while(jinwei)
31 {
32 weishu++;
33 x[weishu-1]=jinwei%10000;
34 jinwei/=10000;
35 }
36 }
37 printf("%d",x[weishu-1]);
38 for(j=weishu-2;j>=0;j--) printf("%04d",x[j]);
39 free(x);
40 return 0;
41 }