// The first nine rows of Pascal's Triangle // // row 0: 1 // row 1: 1 1 // row 2: 1 2 1 // row 3: 1 3 3 1 // row 4: 1 4 6 4 1 // row 5: 1 5 10 10 5 1 // row 6: 1 6 15 20 15 6 1 // row 7: 1 7 21 35 35 21 7 1 // row 8: 1 8 28 56 70 56 28 8 1 // Alternative way to visualize it // // row 0: 1 // row 1: 1 1 // row 2: 1 2 1 // row 3: 1 3 3 1 // row 4: 1 4 6 4 1 // row 5: 1 5 10 10 5 1 // row 6: 1 6 15 20 15 6 1 // row 7: 1 7 21 35 35 21 7 1 // row 8: 1 8 28 56 70 56 28 8 1 public class PascalsTriangle { public static void main(String[] args) { final int DEPTH=9; // Initialize the Memory for the Triangle int[][] P = new int[DEPTH][]; for(int row=0; row < DEPTH; row++) P[row] = new int[row+1]; // Fill in the 0-th row P[0][0]= 1; // Fill in the values of the Triangle for(int row=1; row