Pascal's Triangle

Medium 40 XPPatternsMathDynamic Programming

Commonly asked at Amazon, Google, Zoho

Read n and print the first n rows of Pascal's triangle, numbers separated by spaces (no centring). Each number is the sum of the two numbers above it.

Input
One integer n.
Output
n lines.

Sample 1

Input

5

Output

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.
The solution unlocks after 3 submissions.