The outputs for the test cases work perfectly fine, but if the numbers get big the output gets out wrong
#include<iostream>
using namespace std;
int fact(int n)
{
if (n!=1)
return n* fact(n-1);
}
int main()
{
int t,n;
cin >> t;
while(t--)
{
cin >> n;
cout << fact(n) << endl;
}
return 0;
}
created
last reply
- 1
reply
- 239
views
- 2
users