Why is my Code failing for larger test cases


#1

long long fact(int n)
{
return (n<=1) ? 1:n*fact(n-1);
}
vector<vector > Solution::solve(int A) {
vector<vector>m;
for(int i=0;i<A;i++)
{
vectorv;
for(int j=0;j<=i;j++)
{
int value;
value=(fact(i)/fact(i-j))/fact(j);
v.push_back(value);
}
m.push_back(v);
}
return m;
}


#2

Yaa, even i used the same approach and facing the same problem


#3

factorial function fails for larger test cases, just try finding fact(40), the IDE should crash