i have written the right code and logic but still my test cases are failing.
here is the code,
#include
using namespace std;
int fact(int n)
{
int f=1;
while(n!=0)
{
f=f*n;
n–;
}
return f;
}
int ncr(int n,int r)
{
return fact(n)/(fact®*fact(n-r));
}
int main() {
int n;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<(n-i-1);j++)
{
cout<<" ";
}
for(int j=0;j<=i;j++)
{
cout<<ncr(i,j)<<" ";
}
cout<<endl;
}
return 0;
}