Objective
In Pascal's triangle each row starts and ends with 1, and each middle number is the sum of the two above it in the previous row. It is a recursion: each row is computed from the previous one.
Instructions
- Define
pascal_row(k): row 0 is[1]; rowkis computed frompascal_row(k - 1). - Read
n(the number of rows) and show rows 0 ton - 1, with the numbers of each one separated by a space.
5
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise