113. Pascal's Triangle

Acceptance — 0 accepted 0 submissions

Easy
ArraysMathPatterns
No companies listed
Pascal's triangle (known in India much earlier as Meru Prastara, from Pingala's work) starts with 1. Each number below is the sum of the two numbers just above it.

1
1 1
1 2 1
1 3 3 1
…
Print the first N rows.

Input Format
A single integer N.

Output Format
Print N lines. Line i has the i numbers of row i, separated by single spaces (no leading spaces).

Constraints
• 1 ≤ N ≤ 30

Example 1

Input
5
Output
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Explanation Each inner number is the sum of the two above it.

Example 2

Input
1
Output
1

Explanation Just the top 1.

Example 3

Input
3
Output
1
1 1
1 2 1

Explanation 1 / 1 1 / 1 2 1.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
No results yet
Run your code to test it against the sample cases.
Problem List