Codechef sowing wrong answer

the program
#include
using namespace std;

int main() {
int a,b,c=1;
cin >> a;
while(a!=0)
{
cin >> b;
while(b!=0)
{
c=c*b;
b–;
}
cout<< c<< endl;
c=1;
a–;
}

return 0;

}

1 Like

Can you tell me the problem to which this solution refer…?

1 Like

Small Factorial
I think…

@vipin123
Lets take a=99.
what should be the factorial.
The answer will be so large(more than 140 digits) such that You would not be able to store it in any numeric data type.

1 Like

try to store result in array multiply in array stored result

just insert value in array in reverse order
temp=n;
res=0; i=0;
while(temp--)
{
    while(A.length()){

       res+=temp*A[i];
        A[i++]=res%10;
       res/=10;
   }
   if(res)A[i++]=res;

}

End of code

//