0% found this document useful (0 votes)
49 views

Homework 4a

The document describes Pascal's triangle and provides an algorithm to calculate and print elements of the triangle up to a given row M. It defines Pascal's triangle as a triangular array of binomial coefficients where each interior element is the sum of the two elements above it. The problem is to take in a positive integer M between 1 and 30, and output the Pascal's triangle from row 1 to row M with each element formatted to 10 digits.

Uploaded by

yankev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Homework 4a

The document describes Pascal's triangle and provides an algorithm to calculate and print elements of the triangle up to a given row M. It defines Pascal's triangle as a triangular array of binomial coefficients where each interior element is the sum of the two elements above it. The problem is to take in a positive integer M between 1 and 30, and output the Pascal's triangle from row 1 to row M with each element formatted to 10 digits.

Uploaded by

yankev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

10/8/14, 14:44

10098 - I2P homework4a


Time limit: s
Memory limit: MB

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

You might also like