Pascal's Triangle Generator Lab
In this lab, you will implement a function to generate the first
numRows of Pascal's Triangle. Pascal's triangle is a triangular array of numbers in which each number is the sum of the two numbers directly above it, as shown in the image below:
Your task is to write a function
generate that takes an integer
numRows and returns the first
numRows of Pascal's Triangle in a nested array format.
Input: numRows = 5 Output: [,[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
Input: numRows = 1 Output: []
Input: numRows = 3 Output: [,[1,1],[1,2,1]]
1 <= numRows <= 30
- Implement the
- Export the
generatefunction using ESM export.