119: Pascal‘s Triangle !

Pascal’s triangle is a triangle that gives binomial coefficients of different polynomials. Each row in the triangle tells the degree of the expression. Starting with row 0, row 1, row 2 etc we can build the triangle to say from the previous row. The first number in row n is the sum of the first and next number in row n-1, and does goes on. But now in this post, I am trying to come up with a pattern row formula and here is each step in my formula making! 

We start with row 0 and row 1 as given. 

Let’s say the row number is n. So row 0 means n=0.

Let’s say the number of terms in a row is t, so first row where n=0, t=1.

n=1, t=2

n=2, t=3

n=3, t=4

Let’s say the coefficients in each row is ct. 

so row 0, t=1 so, c1=1

Row 1, t=2, c1=1, c2=1

Row 2, t=3, c1=1, c2=2, c3=1

Row 3, t=4, c1=1, c2=3, c3=3, c4=1

Row 4, t=5, c1=1, c2=4, c3=6, c4=4, c5=1

So, the pattern is as follows:

For a given row n, 

The number of terms t=n+1

The number of coefficients is number of terms, t.

The main part is calculating the value of the coefficients.

The first and last coefficients are always 1.

C1 = ct

Second from left = second from right or c2=c(t-1)

Third from left = third from right or c3=c(t-2) and so on

C(1+x) =C(t-x) – increment x until 1+x >= t-x

Now, calculating other coefficients in the row.

Another pattern is that c2=n=c(t-2) ; 

so row n=2, c2=2

so row n=3, c2=3=c3

Now really didn’t find the pattern for terms above row n=3.

My formula can build the Pascal’s triangle up to row 3.

For row n= 0 to 3, 

 t = n+1

C(1+x) = C(t-x) until 1+x >= t-x

Repeat until n=3.

I also think really there is a easy formula for this to calculate the complete triangle.

One thought on “119: Pascal‘s Triangle !

  1. Cool. Try this:
    for each row n: for r =0 to n: coeff = n! /(r! * (n-r)!)
    where ! = factorial. Start at row n=0

Leave a Reply

Your email address will not be published. Required fields are marked *