⏱ 00:00
Attempts:0
Best: 0/100
Mathematical CombinatoricsTarget Time: 15 mins
Pascal Triangle
Given an integer N, print Pascal’s Triangle of N rows. Each row i starts with (N - i) leading spaces and the binomial coefficients C(i-1, k) separated by a space.
Input Format
A single integer N.
Output Format
Print N rows forming Pascal’s Triangle with single space between numbers.
Constraints:1 <= N <= 12
Concepts Required:
Binomial coefficients C(n, k)Centered formattingNext term calculation formula: val = val * (i - j) / j
Expected Pattern PreviewASCII Monospace
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Notice how character spacing and row counts scale systematically based on the input N.
Concrete Examples
Example 1
Input:
5
Output:
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Explanation: Each number is the sum of the two directly above it.
