Hello guys I need some help about the Pascal's Triangle. It's not about showing an output of the triangle itself but it's a little different.
The user will be asked to choose a row number in the triangle. After that, it will output the sum of all the values above the given row and another output which has the sum of all the numbers on the next row given. Please help me.
Here is the Pascal's Triangle that I know so far.
public class PascalTriangle {
public static void main(String args[]) {
int x = 10;
int triangle[][] = new int[x][x];
for (int i = 0; i < x; i++) {
for (int j = 0; j < x; j++) {
triangle[i][j] = 0;
}
}
for(int i = 0; i < x; i++) {
triangle[i][0] = 1 ;
}
for (int i = 1; i < x; i++) {
for (int j = 1; j < x; j++) {
triangle[i][j] = triangle[i-1][j-1] + triangle[i-1][j];
}
}
}
}