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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started