Back to course home
0% completed
Vote For New Content
8. Pascal's Triangle
Problem Statement:
Write a Recursive Solution to Generate Pascal's Triangle.
Write a recursive function to generate Pascal's Triangle up to a given number of rows. Pascal's Triangle is a triangular array of binomial coefficients, where each number is the sum of the two numbers directly above it.
Example:
Sr# | Input | Output | Explanation |
---|---|---|---|
1 | numRows = 3 | [[1],[1,1],[1,2,1]] | The first 3 rows of Pascal's Triangle are [[1],[1,1],[1,2,1]]. |
2 | numRows = 5 | [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] | The first 5 rows of Pascal's Triangle are [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]. |
3 | numRows = 1 | [[1]] | The first row of Pascal's Triangle is [[1]]. |
Constraints:
1 <= numRows <= 30
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible