#include<stdio.h>
#define max 150
int arr[max],length=1;
factorial(int);
main()
{
int T=0 ,n=0,i=0,j=0,k=0;
int temp,x;
int out[150];
scanf("%d",&T);
arr[0] = 1;
for(i=0;i<T;i++)
{
scanf("%d",&n);
factorial(n);
for(j=length-1;j>=0;j--)
{
out[k] = arr[j];
k++;
}
out[k] = 100;
k++;
arr[0]=1;
for(j=length-1;j>0;j--)
{
arr[j]=0;
}
length=1;
}
for(j=0;j<k;j++)
{
if(out[j]==100)
{
printf("\n");
}
else
printf("%d",out[j]);
}
}
factorial(int n)
{
int i,j,x,temp=0;
for(i=2;i<=n;i++)
{
for(j=0;j<length;j++)
{
x= arr[j]* i + temp;
arr[j] = x%10;
temp = x/10;
}
if(temp !=0)
{
while(temp!=0)
{
length++;
arr[j] = temp%10;
temp = temp /10 ;
j++;
}
}
}
}
my code works fine for even 400! but im getting and error of “Runtime Error(SIGSEGV)” while submmitting the answer can anybody plz help me out here and tell me what to be corrected ? …