Generates and displays Pascal's triangle up to row N. See Pascal's triangle — Wikipedia.
Each entry is the sum of the two entries directly above it. Row n contains the binomial coefficients C(n,0), C(n,1), ..., C(n,n).
Built using dynamic programming — each row is derived from the previous one in O(n) time.
python pascal_triangle.pyPrompts for N and prints the first N+1 rows, centred.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1