 # FCTRL2 small factorial problem for beginner

code is working on ide but not on codechef. what’s the problem?

``````#include <stdio.h>
int main()
{
unsigned long long int t,n,fact=1;
printf("enter number of lines");
scanf("%llu",&t);
if(t>=1 && t<=100)
for(int i=0;i<t;i++)
{
printf("\n Enter number");
scanf("%llu",&n);
if(n>=0&&n<=100)
{
fact=1;
for(int j=1;j<=n;j++)
{
fact=fact*j;
}
printf("\n factorial is %llu",fact);
}
}
return(0);
}``````
``````printf("\n Enter number");
``````
``````printf("\n factorial is %llu",fact);
``````

It is a machine checking if what you print is exactly equal to whats feeded into the expected output file or not. Its clearly stated that you are expected to ONLY print the answer. Any superfluous print statement will lead to WA.

Factorial of 100! contains a lots of digits(93, 326, 215, 443, 944, 152, 681, 699, 238, 856, 266, 700, 490, 715, 968, 264, 381, 621, 468, 592, 963, 895, 217, 599, 993, 229, 915, 608, 941, 463, 976, 156, 518, 286, 253, 697, 920, 827, 223, 758, 251, 185, 210, 916, 864, 000, 000, 000, 000, 000, 000, 000, 000)you can count it yourself!!

there is no data type particularly in cpp which can hold such a big digit.

here is what you can do

declare an array of at most 200 integers and then perform multiplication method like we did in our 4th or 5th class.

for example 120 X 6

first multiply 6 to 0 ans comes out be 0 put 0 in first element of another array then multiply 6 to 2 ans comes out to be 12 put 2 in the second element of array and keep 1 aside for a moment. then multiply 6 to 1 ans comes out be to be 6 add 1 to it, it became 7 and then put 7 in the third element.

in this way you can find the value of 100!.

HOPE YOU GOT IT!!