Homework 4a
Homework 4a
Problem Description
As described in Wikipedia, Pascal's triangle is a triangular array of the binomial coefficients. The element
k on row n of Pascals 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 nonnegative integer M, display the Pascals triangle from row 1 to row M.
Use '%10d' to print each element. Print a newline '\n' at the end of each row.
Input
A positive integer M (1<=M<=30)
Output
Print the Pascal triangle from level 1 to level M.
Sample Input
4
Sample Output
1
1
1
1
1
2
3
1
3
http://140.114.86.238/problem_print.php?pid=10098
Page 1 of 1