#C12397. Recursively Generate Pascal's Triangle

    ID: 41819 Type: Default 1000ms 256MiB

Recursively Generate Pascal's Triangle

Recursively Generate Pascal's Triangle

In this problem, you are required to generate Pascal's Triangle up to ( n ) rows using a recursive approach. Pascal's Triangle is a triangular array of the binomial coefficients defined by ( C(n,k) = \frac{n!}{k!(n-k)!} ), where the first row is [1] and each subsequent row is formed by summing adjacent elements of the previous row with 1's inserted at both ends. You need to output the triangle in a formatted manner where each row is printed on a new line and each number is separated by a space. If ( n = 0 ), output an empty string.

inputFormat

The input consists of a single integer ( n ) (0 ( \leq ) n ( \leq 25 )) which represents the number of rows of Pascal's Triangle to generate.

outputFormat

Output the first ( n ) rows of Pascal's Triangle in formatted form. Each row should be on a separate line with numbers separated by a single space. If ( n = 0 ), output an empty string.## sample

0