Question: JAVA Write a method: int [] pascal(int i) that returns an i by i array containing the first i rows of Pascal's Triangle. Pascal's triangle
JAVA
Write a method:
int [] pascal(int i)
that returns an i by i array containing the first i rows of Pascal's Triangle. Pascal's triangle begins with a single ones in the first row, two ones in the second row, and each subsequent row is filled with the pair-wise sums of the two nearest items above. Here are the first 5 rows:
1
1. 1
1. 2 1
1. 3 3 1
1. 4 6 4 1
All of the values in your output should be as far as possible to the left of their respective array rows, and unused positions should be filled with zeros, thus, your internal representation for the first 5 rows will look like:
1. 0 0 0 0
1. 1 0 0 0
1. 2 1 0 0
1. 3 3 1 0
1. 4 6 4 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
