#55Medium
Pascal's triangle
Time: 1 s · Memory: 256 MB
- Nested loops
Statement
Print the first rows of Pascal's triangle. Every row starts and ends with , and every number in the middle is the sum of the two neighbouring numbers in the row above:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Input format
A single integer ().
Output format
lines: line contains numbers separated by spaces.
Examples
Input
5
Output
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Input
1
Output
1
Note
Keep the previous row and build the next one from it: element of the new row is the sum of elements and of the previous row. The largest number is — it fits into an int.
