Pascal's triangle

How can I find this equation ? Derived from where ?
x = x * (i -k) / (k +1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

using namespace std;
int main()
{
	int n, k, i, x;
	cout << "Enter number of rows for Pascal's Triangle: ";
	cin >> n;

	for (i=0; i<=n ; i++) {
		x=1;
		for( k=0; k<=i; k++) {
			cout << x << '\t';
			x = x * (i -k) / (k +1); // How can I find this equation ?
		}
		cout << endl;
	}
	return 0;
}
this http://en.wikipedia.org/wiki/Binomial_coefficient will help you
each term in the triangle is calculated by n choose k

where n choose k is
n!/((n-k)!*(k)!)

you will have to code the choose and factorial functions as they are not included in the cmath file.
Topic archived. No new replies allowed.