4. On graph paper, a stepped right-angled triangle with legs equal to 6 cells (see fig.) was drawn. Then all the grid lines inside the triangle were outlined. What is the maximum number of rectangles that can be found in this drawing?
Answer: 126

Solution: For each cell, find the number of rectangles in which this cell is the top right corner. This is not difficult to do, you can simply multiply the cell number horizontally and vertically (if starting from the lower left corner and numbering from one).

|  |  |  |  |  |  |  |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| 6 |  |  |  |  |  |  |
| 5 | 10 |  |  |  |  |  |
| 4 | 8 | 12 |  |  |  |  |
| 3 | 6 | 9 | 12 |  |  |  |
| 2 | 4 | 6 | 8 | 10 |  |  |
| 1 | 2 | 3 | 4 | 5 | 6 |  |
|  |  |  |  |  |  |  |
|  |  |  |  |  |  |  |

Summing the numbers by columns: $1+\ldots+6+2(1+\ldots 5)+3(1+\ldots 4)+4(1+\ldots 3)+5(1+2)+6=21+$ $30+30+24+15+6=126$.