#include
using namespace std;
int main() {
//for 100 factorial it is showing wrong answer
long long n;
int ans=1;
cin>>n;
if(n>=1 && n<=500)
{
for(int i=n;i>=1;iā)
{
ans*=i;
}
}
cout<<ans;
}
How to solve factorial problem for n=100
test cases are very large as they can go till 500 and normal it cant store that long answer
you have to use array in this.
1 Like