I need to recall a certain formula for Pascal's triangle which allows you to get a number in a certain row, column using the row and column you need along with other information I can't remember. Yea I know I am specific huh :P
Any way I would appreciate some help on this. I have looked around google for some page describing some formula but kept coming up with nothing.
ID:277970
Oct 17 2008, 7:25 am
|
|
In response to DarkCampainger
|
|
DarkCampainger wrote:
http://en.wikipedia.org/wiki/ Pascal_triangle#Calculating_an_individual_row Not exactly the formula but I am going to see if I can change it a bit to fit my needs. Thanks DarkCampainger. |
n!/(r!(n-r)!) is the formula you're looking for (where n is the row and r is the column and the factorial notation means n! = 1 * 2 * ... * (n-1) * n). This is better known as nCr on your calculator (pronounced n choose r).
It can be proven by induction. |
In response to Abhishake
|
|
Abhishake wrote:
nCr (pronounced n choose r). Are you sure about that? I thought the C stands for "combination," and the P "permutation." |
In response to Loduwijk
|
|
It does stand for that but it's still pronounced "n choose r" because a combination means you're choosing r objects from n objects. Perhaps it's a British convention and not an American one. For example, I've heard Americans sometimes pronounce "5!" as "5 shriek", where as we always call it "5 factorial".
|
In response to Abhishake
|
|
I was always taught that 5! is factorial. If I heard someone say shriek again I would probably yell at them.
George Gough |
Using the formula mentioned earlier to find the rth item in the nth row of Pascal's triangle would be slower than generating Pascal's triangle then grabbing the value from that (a method called memoization). The advantage is that you can also choose to use it later after you've generated as many rows as you need. Unless you only need one value from the twentieth row during the runtime of your program, then this way would be faster.
|
In response to Abhishake
|
|
Abhishake wrote:
n!/(r!(n-r)!) is the formula you're looking for (where n is the row and r is the column and the factorial notation means n! = 1 * 2 * ... * (n-1) * n). This is better known as nCr on your calculator (pronounced n choose r). No that is not the formula I was looking for. DarkCampainger was much closer. The formula I was looking for definitely did not use factorial notation. Besides this post is dead. |
For posterity, the formula as worked out in BYOND code would be as follows:
/* Lummox JR |
Is that what you were looking for?