0

I'm new here, but it looks like an awesome place to get some help.

My assignment is to write a recursive function that determines the value of a unit of Pascal's triangle given the row and column, then use that to display the triangle with n number of rows. It's taken me quite a while to just understand how the Pascal's triangle works, much less code it. I don't totally understand the mathematical logic for it. I've finally coded it with an iterative loop, but I'm not sure I can figure it out recursively... or if I am supposed to... anyway, I've got my plain vanilla loop coded here.

```
#include <iostream>
using namespace std;
int main()
{
int n,k,i,x;
cout << "Enter a row number for Pascal's Triangle: ";
cin >> n;
for(i=0;i<=n;i++)
{
x=1;
for(k=0;k<=i;k++)
{
cout << x << " ";
x = x * (i - k) / (k + 1);
}
cout << endl;
}
return 0;
}
```

If anybody can help or guide me, it'd be great.