- Foundation
- About 11 min
- 5 practice questions
Counting rectangles in a grid
Count all rectangles in a grid of cells by choosing pairs of grid lines, and see how squares fit inside the total.
If something looks wrong, please tell us.
A rectangle on a grid is fixed by choosing two vertical lines and two horizontal lines. This turns the problem into choosing pairs, just as for segments on a line. A square is also a rectangle, so a rectangle count includes all the squares.
The rule
A grid with m rows and n columns of cells has m plus 1 horizontal lines and n plus 1 vertical lines. The number of ways to choose 2 horizontal lines is (m plus 1) times m, divided by 2. The number of ways to choose 2 vertical lines is (n plus 1) times n, divided by 2. Multiply the two numbers.
Rectangles in an m by n grid of cells = [m(m+1)/2] times [n(n+1)/2].
| Grid (rows by columns) | Pairs of horizontal lines | Pairs of vertical lines | Rectangles |
|---|---|---|---|
| 1 by 3 | 1 | 6 | 6 |
| 2 by 2 | 3 | 3 | 9 |
| 2 by 3 | 3 | 6 | 18 |
| 3 by 3 | 6 | 6 | 36 |
| 4 by 4 | 10 | 10 | 100 |
Worked examples
Example 1. How many rectangles are in a 2 by 3 grid? Working: pairs of horizontal lines: 3 lines give 3 pairs. Pairs of vertical lines: 4 lines give 6 pairs. 3 times 6 is 18. Answer: 18.
Example 2. How many rectangles that are not squares are in a 3 by 3 grid? Working: total rectangles are 36; squares are 14. 36 minus 14 is 22. Answer: 22.
Example 3. A strip of 1 row and 5 cells: how many rectangles? Working: one row has 2 horizontal lines, which give 1 pair. The 6 vertical lines give 6 times 5, divided by 2, which is 15 pairs. 1 times 15 is 15. Answer: 15.
Key takeaways: choose two vertical and two horizontal lines; multiply; subtract the squares to get the non-square rectangles.
Check your understanding
-
1. How many rectangles (squares included) are there in a 2 by 2 grid?
- 9
- 12
- 16
- 18
Show answer
Answer: A. There are 3 horizontal and 3 vertical lines, each giving 3 pairs. 3 x 3 = 9.
-
2. How many rectangles are there in a grid of 3 rows and 4 columns of cells?
- 60
- 72
- 80
- 90
Show answer
Answer: A. 4 horizontal lines give 4 x 3 / 2 = 6 pairs. 5 vertical lines give 5 x 4 / 2 = 10 pairs. 6 x 10 = 60.
-
3. How many rectangles in a 2 by 2 grid are NOT squares?
- 2
- 3
- 4
- 5
Show answer
Answer: C. There are 9 rectangles in all and 5 squares (4 small, 1 large). 9 - 5 = 4.
-
4. How many rectangles are there in a strip of 4 cells in one row?
- 8
- 10
- 12
- 15
Show answer
Answer: B. 2 horizontal lines give 1 pair. 5 vertical lines give 5 x 4 / 2 = 10 pairs. 1 x 10 = 10.
-
5. A grid has 2 rows and 3 columns of cells. How many horizontal and how many vertical lines does it have?
- 2 horizontal and 3 vertical
- 4 horizontal and 3 vertical
- 3 horizontal and 3 vertical
- 3 horizontal and 4 vertical
Show answer
Answer: D. A grid of m rows has m + 1 horizontal lines, and n columns give n + 1 vertical lines. So 2 + 1 = 3 horizontal and 3 + 1 = 4 vertical.
Sign in to keep track of the lessons you finish.