# Small Factorial, I tested my solution against WOLFRAM ALPHA but still wrong answer!!

http://www.codechef.com/viewsolution/6569544

here is my solution.
I’ve checked as many possible cases I can but no use, still WA.

#include<stdio.h>
#include<stdlib.h>
#define MAX 500
//////////////////////////////////////////////
int multiply(int *k,int num,int size)
{

int carry=0,i,j,n;
for(i=0;i<size;i++)
{
j=k[i];
k[i]=((jnum)+carry)%10;
carry=((num
j)+carry)/10;

}

n=carry;
while(carry/10!=0)
{
k[i]=carry%10;
carry=carry/10;
i++;
}
k[i]=carry;
++i;

return i;
}

/////////////////////////////////////////////////
int fill(int *k,int num)
{
if(num/10==0)
{k[0]=num;return 1;}
else if(num==100)
{k[0]=0;k[1]=0;k[2]=1;return 3;}
else
{k[0]=num%10;k[1]=num/10;return 2;}
}
//////////////////////////////////////////////////
void display(int *k,int size)
{
//printf("\n");
//printf(“Display\n”);
int j;
for(j=size-1;j>=0;j–)
{
printf("%d",k[j]);
}
}
/////////////////////////////////////////////////
void fact(int n,int *fac)
{
//printf(“Fact\n”);
num=n;
if(n%2==0)
{j=num/2;foo=0;}
else
{j=num/2+1;foo=1;}
k=(int *)calloc(j,sizeof(int));
if(foo==0)
{
for(i=0;i<j;i++)
{
k[i]=num+temp;
num=k[i];
}
}
else
{
for(i=0;i<j-1;i++)
{
k[i]=num+temp;
num=k[i];
}
k[i]=j;
}

size=fill(&fac[0],k[0]);

for(i=1;i<j;i++)
size=multiply(&fac[0],k[i],size);
display(&fac[0],size);
}

int main()
{

int *k,i,j,n,num,t;

int fac[MAX];

scanf("%d",&t);

for(i=0;i<t;i++)
{
scanf("%d",&n);
if(n==0){printf("%d\n",1);continue;}
fact(n,&fac[0]);
printf("\n");
}
return 0;
}

It is giving the right answer for all the numbers between 1->100, also i’ve put 0!=1.
Plzz help i’ve been on it for 12 hrs now…

this is my code .