Help me with FCTRL2

my code----
#include <stdio.h>

int fact(int x){

int y=1;

while(x!=0){        

y = y*x;

x = x-1;}

printf("%d\n",y);

return 0;

}

int main(){

int n, i, z=1;

scanf("%d",&n);

int num[n];

for(i=0;i<n;i++){

    scanf("%d",&num[i]);

}

for(i=0;i<n;i++){

    if(num[i]==0){

        printf("%d",z);

        continue;

    }

    fact(num[i]);

}

return 0;

}

please let me know whats wrong with my code…

1 Like

The constraint of n is till 100, and via this method, you will not be able to compute such large factorial as 100! has 170 around digits in its decimal representation. The one and only method is that we use the procedural multiplication method, and have to represent your answer as an array of digits. Long long will not be going to work here.

For finding the factorial of a big number, it’s not possible with normal int, long int or long long int as the factorial of 100 have 10^150 digits which is not possible to show using the above data type.
for this problem can check this out
(Find the Factorial of a large number - GeeksforGeeks)