• Home
  • Contents
  • About
​​​​​​​​​​​​​​​​

Friday 17 August 2012

Pascal's Triangle



Pascal triangle is a well known mathematical structure formed out of numbers.To be specific this structure is triangular in shape.The structure was invented by a french mathematician Blaise Pascal.Various patterns on this triangle gives out to triangular numbers,polygonal numbers,squared, Fibonacci and can be used for binomial expansions.

A simple pascal triangle with 6 rows look like below


pascal triangle










The numbers will be have to be generated in rows.

On the first row just place 1 and both its left hand side and right hand side is occupied by zeroes,though not showed in the above image.Every row in the triangle should have it's starting and ending number as zero.so our first row will be exactly like below.

0    1     0

to generate the numbers on the second row

   1.  write down the first zero from row 1 as it is. 0



  =  1
 2.  next from the first row,add the first number with second number 






               =  1
 3.  and then add the second number with the third number 





   4.  Finally write down the last zero as it is which gives us the numbers for the second row as below                                                                                          

                                      


   5.  for generating the third row,we will have to execute the same steps that we followed earlier.

                                    
                                     
                                     
        which would result in following numbers for row 3.
        0   1   2   1  0.

You can keep repeating this and generate as many rows you want in your triangle.


C# Implementation

Here goes the C# Implementation.




Console Output


Console window generating the Pascal triangle for 10 rows



Click here for other Topics


No comments:

Post a Comment