Description We all know how to calculate the factorial of a number, but if the number is large, how do we compute it and output it. Enter an integer m (0<m<=5000) output of the factorial of M, and enter a newline character sample input After the end of the output.
50
Sample output
30414093201713378043612608166064768844377641568960512000000000000
#include <stdio.h>
#include <string.h>
#define N 20000/
* Array can not open too large, timeout, also can not open too small, small WA. *
/int fac[n];
int main ()
{
int s,m,flag=0;
scanf ("%d", &m);
memset (fac,0,sizeof (FAC));
int i,j;
Fac[0] = 1;
for (i=2;i<=m;i++)
{
flag = 0;
for (j=0;j<n;j++)
{
s = fac[j]*i + flag;//flag to carry flag
fac[j] = s%10;
flag = S/10;
}
for (j = n-1;j>=0;j--)
if (fac[j]) break;//Remove leading 0
for (; j>=0;j--) printf ("%d", fac[j));
printf ("\ n");
return 0;
}