What's wrong with this code?

#include
using namespace std;

int main() {
// your code goes her
int t;
cin>>t;
int n;
for(int i=1;i<=t;i++) {
long pro=1;
cin>>n;
for(int j=1;j<=n;j++) {
pro*=j;
}
cout<<pro<<endl;

}
return 0;

}

Practice problem:FCTRL2
no errors but marks the code wrong
If you do know , please comment and have a nice day

Try input :
1
100

Expected O/P - 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

Your O/P - 0

For larger factorial you will need to use some other method to find factorial as 100 factorial contains almost 150 digits where long long can hold up to 18 digits only .

Google how to find factorial of large number in c++ or find it on yt .

2 Likes

Please be a responsible member of the forum by looking up the word FCTRL2 before starting a new topic…like they’re literally 50+ results that could’ve easily helped you.

2 Likes

Hi,

You first need to study the various data types available in your language and learn the definition of factorial before attempting this problem!