## The Pascal's Triangle (aka Chinese Triangle) was named after French mathematician, physicist, inventor, writer and religious philosopher Blaise Pascal (1623-62).

The number at the top row (the point) of a Pascal's Triangle is `1`

.

More numbers are placed in rows to form a triangular pattern.

The numbers at the start and at the end of each row are all `1`

.

Each other number inside the triangle is the sum of the two numbers above it.

Start with `0`

when refering to rows from the top vertex to the base and start with `0`

when refering to the numbers (cells or columns) in each row from left to right.

### Symmetrical

Dividing the Pascal's Triangle from the top vertex to the base with a line of symmetry creates two right angled triangles. The numbers (nodes) on the left triangle have symmetrical matching numbers (nodes) on the right triangle.

### Possible Grid Paths

The count of possible grid paths from the top node to a given node corresponds to the value of that given node. As illustrated in the image below, there are four different possible ways from the top node to the node with the value of `4`

.

### Calculating Individual Rows

This is a simple algorithm to calculate all individual cell values for a given row. Remember that we refer to the top row as `0`

(`n = 0`

) and we refer to the first cell of a row also as `0`

(`k = 0`

). We also know that each row starts with the number `1`

, e.g. the value of the first cell within a row equals `1`

.

#### Formula

( | row (n) | ) | First row and first (and only) cell = | ( | 0 | ) | = | 1 | First cell within a row (n) = | ( | n | ) | = | 1 | ||

cell (k) | 0 | 0 |

Subsequent cell values | = | ( | n | ) | = | ( | n | ) | × | n + 1 - k |

k | k - 1 | k |

### Calculating Individual Cell Values

This is a simple algorithm to calculate all individual cell values for a given row.

#### Formula

( | n | ) | = | n! |

k | k!(n - k)! |

#### Worked Examples

Find the value of the fourth number (`cell (k) = 3`

) in the fifth row (`row (n) = 4`

).

( | 4 | ) | = | 4! | = | 4! | = | 4 × 3 × 2 × 1 | = | 4 × 3 × 2 × 1 | = 4 |

3 | 3!(4 - 3)! | 3!1! | 3 × 2 × 1 × 1 | 3 × 2 × 1 × 1 |

Find the value of the third number (`cell (k) = 2`

) in the fifth row (`row (n) = 4`

).

( | 4 | ) | = | 4! | = | 4! | = | 4 × 3 × 2 × 1 | = | 4 × 3 × 2 × 1 | = | 12 | = 6 |

2 | 2!(4 - 2)! | 2!2! | 2 × 1 × 2 × 1 | 2 × 1 × 2 × 1 | 2 |

Find the value of the second number (`cell (k) = 1`

) in the sixth row (`row (n) = 5`

).

( | 5 | ) | = | 5! | = | 5! | = | 5 × 4 × 3 × 2 × 1 | = | 5 × 4 × 3 × 2 × 1 | = 5 |

1 | 1!(5 - 1)! | 1!4! | 1 × 4 × 3 × 2 × 1 | 1 × 4 × 3 × 2 × 1 |