why is this wrong? Re

using namespace std;
int main(){
int n,a[100];
for(int i=0;i<n;i++){
int fact=1;
for(int j=1;j<a[i]+1;j++)
fact = fact*j;
for(int i=0;i<n;i++)
return 0;

Factorial values quickly get huge. You should check what value your current code fails at, which isn’t hard to find out with a decent test set. Then think about using more suitable data types (long long perhaps?) and protect against over-limit values. If the answer you are looking for is taken to some modulus then perhaps incorporate that into the function.