You are asked to calculate factorials of some small positive integers.
Input
An integer t, 1<=t<=100, denoting the number of testcases,
followed by t lines, each containing a single integer n,
1<=n<=100.
Output
For each integer n given at input, display a line with the value of n!
Example
Sample input:
4
1
2
5
3
Sample output:
1
2
120
6
//THE end digits are correct in the answer this gives but no. of zeros is not 24 at the end?!!
#include<stdio.h>
#include<stdlib.h>
void main()
{
int big[160];
int l,prod=0,store=0,carry=0,k,s,
i;
//int storer[160];
//to assigne null value to every element of the set
for(i=0;i<=160;i++)
{
big[i]=0;
}
big[0]=1;
printf("enter small\n");
scanf("%d",&s);
int j=1;
while(j<=s)
{
prod=0,store=0,carry=0,k;
i=0;
//to calculate the product and store it
do
{
//if(big[i]!=0) - seems like an unecessary condition
prod=big[i]*j;
prod=prod+carry;
store=prod%10;
carry=prod/10;
big[i]=store;
i++;
}while(i<l);
l=i+2;
if(big[l]==0){l=l-1;} //new condition added
j++;
}
//to pint the answer array
for(k=i;k>=0;k--)
{
printf("%d",big[k]);
}
getch();
} //THE END