10151 - Lab04   

Description

As described in Wikipedia, Pascal's triangle is a triangular array of the binomial coefficients. The element k on row n of Pascal’s triangle can be calculated by the following relation:
C(n, 1) = 1, for n = 1, 2, …
C(n, n) = 1, for n = 1, 2, …
C(n, k) = C(n-1, k-1) + C(n-1, k),  for k = 2, 3, … and for n = 2, 3, …

Given a sequence of numbers, please print the corresponding rows of the Pascal’s triangle.
Use '%10d' to print each element. Print a newline ' ' at the end of each row.

Hint:
You should first create a Pascal’s triangle from row 1 to row 30.

Input

A sequence of positive integers, and each of them is smaller than 31.

Output

Print the corresponding rows of the Pascal’s triangle.

Sample Input  Download

Sample Output  Download

Tags




Discuss