Given an integer numRows
, return the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:
Example 1:
Input: numRows = 5 Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
Example 2:
Input: numRows = 1 Output: [[1]]
Ashutosh Kumar Verma
13-Jun-2024Pascal's Triangle
Pascal’s triangle is a geometric arrangement of binomial factors in a square. Each number in a square is the sum of the two directly above it. It is named after the French mathematician Blaise Pascal, although he was known in various parts of the world long before his time.
Sample of Pascal's triangle with 5 rows
The number at the edge of the triangle is always 1, and each inner number is the sum of the two digits above it. This process is continuous.
Example-
Here is a basic C# example to demonstrate Pascal's triangle,
Output-
Also, Read: What is out keyword in C#?