• Practice
  • About 13 min
  • 5 practice questions

Rectangles and squares in an m by n grid

Count all rectangles and all squares in a grid of unit squares that is m wide and n tall, using pair-choosing and size-by-size counting.

If something looks wrong, please tell us.

A grid of unit squares that is m squares wide and n squares tall hides many rectangles. The rule is a direct extension of the pair rule.

Rectangles

A rectangle is fixed by choosing 2 of the m plus 1 vertical lines and 2 of the n plus 1 horizontal lines. So the number of rectangles, squares included, is C(m plus 1, 2) times C(n plus 1, 2).

Squares

Squares of side k fit in (m minus k plus 1) times (n minus k plus 1) places. Add over all k up to the smaller of m and n.

Worked examples

Example 1. A grid 3 wide and 2 tall. Rectangles: C(4, 2) times C(3, 2) = 6 times 3 = 18. Squares: side 1, 3 times 2 = 6; side 2, 2 times 1 = 2. Total 8.

Example 2. A grid 4 wide and 3 tall. Rectangles: C(5, 2) times C(4, 2) = 10 times 6 = 60. Squares: side 1, 4 times 3 = 12; side 2, 3 times 2 = 6; side 3, 2 times 1 = 2. Total 20.

Example 3. A grid 5 wide and 2 tall. Rectangles: C(6, 2) times C(3, 2) = 15 times 3 = 45. Squares: side 1, 10; side 2, 4. Total 14.

Rectangles: C(m plus 1, 2) times C(n plus 1, 2). Squares: add (m minus k plus 1)(n minus k plus 1) for each side k.

— Rule to remember

Key takeaways

  • Rectangles: choose 2 vertical and 2 horizontal lines.
  • Squares: count by side length and add.
  • Squares are a subset of the rectangles.

Check your understanding

  1. 1. How many squares of all sizes are there in a grid 3 wide and 2 tall?

    1. 5
    2. 6
    3. 7
    4. 8
    Show answer

    Answer: D. Side 1: 3 x 2 = 6. Side 2: 2 x 1 = 2. No side-3 square fits in 2 rows. Total 8.

  2. 2. How many rectangles of all kinds are there in a grid 4 wide and 2 tall?

    1. 24
    2. 30
    3. 36
    4. 40
    Show answer

    Answer: B. C(5, 2) x C(3, 2) = 10 x 3 = 30.

  3. 3. How many squares of all sizes are there in a grid 4 wide and 2 tall?

    1. 8
    2. 9
    3. 10
    4. 11
    Show answer

    Answer: D. Side 1: 4 x 2 = 8. Side 2: 3 x 1 = 3. Total 11.

  4. 4. How many rectangles of all kinds are there in a grid 3 wide and 3 tall?

    1. 27
    2. 36
    3. 49
    4. 81
    Show answer

    Answer: B. C(4, 2) x C(4, 2) = 6 x 6 = 36.

  5. 5. How many rectangles of all kinds are there in a grid 5 wide and 1 tall?

    1. 6
    2. 10
    3. 15
    4. 21
    Show answer

    Answer: C. C(6, 2) x C(2, 2) = 15 x 1 = 15.

Privacy · Terms · Refunds · Delivery