(int n)
| 9 | // 1 2 3 |
| 10 | // 1 2 3 4 |
| 11 | static void pattern4(int n) { |
| 12 | for (int row = 1; row <= n; row++) { |
| 13 | // for every row, run the col |
| 14 | for (int col = 1; col <= row; col++) { |
| 15 | System.out.print(col + " "); |
| 16 | } |
| 17 | // when one row is printed, we need to add a newline |
| 18 | System.out.println(); |
| 19 | } |
| 20 | } |
| 21 | } |