Small Factorials-C code working on PC but not on code chef

helloo…my code is giving correct answer on PC but wrong on Code chef. Someone…please help me out what is wrong with this code.

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

#include<stdio.h>
void main()
{
    int a[200],k,num,b[100],i=0,j,m,n,temp,x,t;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d",&b[i]);
    }
    for(k=0;k<t;k++)
    {
        num=b[k];
        a[0]=1;
        for(i=1,m=1;i<=num;i++)
        {
            for(j=0,temp=0; j<=m-1 ;j++)
            {
                x=a[j]*i+temp;
                a[j]=x%10;
                temp=x/10;
            }
            for(;temp>0;j++,m++,temp/=10)
                a[j]=temp%10;
        }
        for(j=m-1;j>=0;j--)
            printf("%d",a[j]);
        printf("\n");
    }
 
}

ur logic is correct…the only error is that ur code is not returning 0…which is leading to a RE…NZEC(non zero exit code)!!! so just make ur main method “int main” and add a “return 0” statement at the end…hope this helps…:slight_smile:

3 Likes

ohhh thanks a lot…!!! :slight_smile: :slight_smile:
it works now :slight_smile:

glad could help…:slight_smile:

1 Like

:slight_smile: :slight_smile: !!!

//