here is my code:
#include
using namespace std;
int multiply(int i,int r[],int r_size)
{
int carry=0;
for(int j=0;j<r_size;j++)
{
int prod=i*r[j]+carry;
r[j]=prod%10;
carry=prod/10;
}
while(carry)
{
r[r_size]=carry;
carry=carry/10;
r_size++;
}
return r_size;
}
void factorial(int n)
{
int r[2500];
r[0]=1;
int r_size=1;
for(int i=2;i<=n;i++)
{
r_size=multiply(i,r,r_size);
}
for(int j=r_size-1;j>=0;j–)
{
cout<<r[j];
}
}
int main() {
int n;
cin>>n;
factorial(n);
return 0;
}
sir when i run the code it gives right answers for all n<=500 but when i submit the code all 7 test cases show worng answer error.It means there is no problem regarding time limit but something else that i can’t figure out?
