What is it that you do not understand? The ordering of the numbers specifically, or the whole thing? Do you understand the for loop etc? I presume you will do like. What it seems to be: // 1 for each row in the pyramid for (int row = 1; row <= NUM_OF_LINES; row++) Creates the rows - NUM_OF_LINES is initialised with a value of 5, so the program will go round the loop 5 times, thus producing 5 lines. // 1.1 print leading spaces for (int col = 1; col <= NUM_OF_LINES -row; col++) System.out.print(" "); this appears to make the spaces so that the output of numbers will actually appear as a pyramid. Then for the leading and ending numbers: // 1.2 print leading numbers for (int num = row; num >= 1; num--) System.out.print(num); // 1.3 print ending numbers for (int num = 2; num <= row; num++) System.out.print(num); when the number = row, to number >=1, the number will count down. Then when the number = 2, to when the num <= row, the numbers increment. eg on line 2 - thats row 2, therefore will start with 2, then go to 1. This ends the first loop, and the program moves on to the next loop, and counts up until the number of the row corresponds to the highest number in that particular row. Therefore. On row 1, there can only be 1 number, on row 2, it will be 212, and so on. I only do C++ but the logical flow is the same. Hope thats been of some help