#K8466. Pascal's Triangle Generation

    ID: 36469 Type: Default 1000ms 256MiB

Pascal's Triangle Generation

Pascal's Triangle Generation

Given an integer n, generate the first n rows of Pascal's Triangle. Recall that Pascal's Triangle is defined such that each element is the sum of the two elements directly above it. In particular, the value of each element can be represented by the binomial coefficient $$\binom{n}{k}$$. The first and last number in each row is always 1.

For example, for n = 5, the triangle is:

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

Write a program that reads input from stdin and prints the corresponding Pascal's Triangle to stdout with each row on a new line and numbers separated by a single space.

inputFormat

The input is a single integer n (1 ≤ n ≤ 50) from stdin denoting the number of rows of Pascal's Triangle to be generated.

outputFormat

Print the Pascal's Triangle with n rows. Each row should be printed on a new line with each number separated by a single space. Ensure the output ends with a newline.## sample

1
1

</p>