Wrong answer for small factorials problem

Below is my code for the FCTRL2 problem,i have seen that it works correctly for all the inputs,i am not sure for what reason i am getting wrong answer and my answer is not being accepted.
Can anyone help? thanks.

 #include <stdio.h>
 int main()
{

    int t;
    scanf("%d",&t);
    while (t--) {
        
     int n,x=0,i,j,temp=0,a[200],k;
      
    scanf("%d",&n);
       int m=1;
          a[0]=1;
    for (i=1; i<=n; i++) {
        for (j=0; j<m; j++) {
            x=a[j]*i+temp;
            a[j]=x%10;
            temp=x/10;
        }
        while (temp>0) {
            a[m]=temp%10;
            temp=temp/10;
            m++;
            
        }
    }
        for (k=m-1; k>=0; k--) {
            printf("%d",a[k]);
        }

    }
}

You missed printf("\n"); after printing the factorial :smiley: Your AC Code

1 Like

@vnhrmth

You are not printing result on newline. Just add

printf("\n");

after last for loop.

I just added newline and code was accepted.

You may check this link [Your implementation with modification ]: http://www.codechef.com/viewsolution/5236452

wow…that was close,thanks

thanks, i guess i missed that