Pascal’s Triangle in Python

The numbers in the graphic below form the first five rows of Pascal's Triangle, which in this post I will implement in Python.

The first row consists of a single number 1. In subsequent rows, each of which is has one more number than the previous, values are calculated by adding the two numbers above left and above right. For the first and last values in each row we just take the single value above, therefore these are always 1.

Pascal's Triangle

Pascal's Triangle in its conventional centred layout

Continue reading