This triangle shape full of numbers is the reference I have to use for the first part of a homework problem, but I haven't the slightest clue as to why the rows and columns are indexed starting at zero and what that means in terms of all the other rows.

That being said:

How does P(4,2)=6?

It doesn't make any sense to me.

Note: I used parentheses to make up for the fact that I couldn't type in a small '4' and a small '2'.



9 Years
Discussion Span
Last Post by sobam15

I've figured out the answer to my previous question, but now have an even bigger problem. The assignment was to create and run a program that can take any column and row then print the corresponding number.

I found this code online. I thinks it's the answer. I don't want the answer. I want to know why and how to do it:


for ($k=0;$k<10;$k++) {
     $pascal[$k] = [];
     push @{$pascal[$k]},1;
     for ($l=1;$l<=$k;$l++) {
        push @{$pascal[$k]},$pascal[$k-1][$l-1]+$pascal[$k-1][$l];

foreach (@pascal) {
        $n_els = @{$_};
        $nsp = 20 - 2 * $n_els;
        $form = (" " x $nsp).("%4d" x $n_els)."\n";
        printf $form, @{$_};

I really need it explained... in absolute layman's terms if it is at all possible.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.