Small Factorial

what is wrong is this code, codechef is showing wrong answer?


using namespace std;

int fact (int x){

if(x &lt;=1){

return 1;


return x*fact(x-1);


int main(){

int t;


int arr[t];

for(int i = 0<t;i++){

int x;

        cin>> x;

        arr[i]=fact(x) ;


for(int i = 0; i <t; i++)





Hi @hardy_971.

N can be 100 in worst case. 100 factorial is a huge number, and won’t fit in int type.

You can refer to to understand how to solve the question.

Hope this helped :slight_smile:

1 Like