N!

Time Limit: 1000 MS   Memory Limit: 32768 K

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

1
2
3

Sample Output

1
2
6
#include<stdio.h>
int main()
{
    int s[40000],i,j,t,n,c,num;
    while (scanf("%d",&n)!=EOF)
    {
        s[0]=1;t=1;c=0;
        for (i=2;i<=n;i++)
        {
            for (j=0;j<t;j++)
            {
                num=s[j]*i+c;
                c=num/10;
                s[j]=num%10;
            }
            while (c)
            {
                s[t++]=c%10;
                c/=10;
            }
        }
        for (i=t-1;i>=0;i--)
            printf("%d",s[i]);
        printf("\n");
    }
    return 0;
}