954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

The Pascal Triangle

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'.

Thanks.

-sobam15

sobam15
Newbie Poster
4 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Do you have some perl code you need help with?

KevinADC
Posting Shark
921 posts since Mar 2006
Reputation Points: 246
Solved Threads: 67
 

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:

#!/usr/bin/perl

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.

-sobam15

sobam15
Newbie Poster
4 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You