• Practice
  • About 13 min
  • 5 practice questions

Hidden squares and rectangles in grids

Count the squares and rectangles hidden in square grids using size-by-size counting and a short formula for rectangles.

If something looks wrong, please tell us.

A square grid is the classic embedded-figure puzzle: many squares and rectangles are hidden in a few lines. A system makes the counting reliable.

Squares: count by size

In an n by n grid of small squares, the number of squares of side k is (n minus k plus 1) multiplied by itself. Add up the sizes.

Squares in an n by n grid
GridSide 1Side 2Side 3Side 4Total
2 by 241--5
3 by 3941-14
4 by 41694130

Rectangles

A rectangle is chosen by picking 2 of the n plus 1 horizontal lines and 2 of the n plus 1 vertical lines. The count of all rectangles, squares included, is therefore the number of ways to pick 2 lines out of n plus 1, squared. For n = 2 that is 3 times 3 = 9, and for n = 3 it is 6 times 6 = 36.

Worked examples

Example 1. Squares in a 3 by 3 grid: 9 small, 4 of side 2, and 1 of side 3. Total 9 plus 4 plus 1 = 14.

Example 2. All rectangles in a 2 by 2 grid: choose 2 of 3 horizontal lines (3 ways) and 2 of 3 vertical lines (3 ways): 3 times 3 = 9. Of these 5 are squares and 4 are non-square rectangles.

Example 3. Rectangles measuring 1 by 2 (in either direction) in a 3 by 3 grid: horizontal ones, 3 rows times 2 positions = 6; vertical ones, 3 columns times 2 positions = 6. Total 12.

Squares: add up (n minus k plus 1) squared over all sizes k. All rectangles: pick 2 horizontal and 2 vertical lines.

— Rule to remember

Key takeaways

  • Count squares size by size.
  • For rectangles pick two horizontal and two vertical lines.
  • Write the counts in a table to avoid missing a size.

Check your understanding

  1. 1. How many squares of all sizes are in a 4 by 4 grid?

    1. 16
    2. 20
    3. 36
    4. 30
    Show answer

    Answer: D. Side 1: 16; side 2: 3 x 3 = 9; side 3: 2 x 2 = 4; side 4: 1. Total 16 + 9 + 4 + 1 = 30.

  2. 2. How many rectangles of all kinds (squares included) are in a 2 by 2 grid?

    1. 5
    2. 8
    3. 16
    4. 9
    Show answer

    Answer: D. Choose 2 of the 3 horizontal lines (3 ways) and 2 of the 3 vertical lines (3 ways): 3 x 3 = 9.

  3. 3. How many rectangles of all kinds (squares included) are in a 3 by 3 grid?

    1. 14
    2. 36
    3. 16
    4. 24
    Show answer

    Answer: B. There are 4 horizontal and 4 vertical lines. Choosing 2 of 4 gives 4 x 3 / 2 = 6 ways each: 6 x 6 = 36.

  4. 4. How many squares of side 2 are in a 4 by 4 grid?

    1. 4
    2. 8
    3. 9
    4. 16
    Show answer

    Answer: C. Number of squares of side k = (n - k + 1) squared = (4 - 2 + 1) squared = 3 x 3 = 9.

  5. 5. How many of the rectangles in a 2 by 2 grid are NOT squares?

    1. 4
    2. 5
    3. 9
    4. 2
    Show answer

    Answer: A. All rectangles: 9. Squares: 4 small + 1 large = 5. Non-square rectangles: 9 - 5 = 4 (two horizontal halves and two vertical halves).

Sign in to keep track of the lessons you finish.

Next lesson → Hidden triangles

Privacy · Terms · Refunds · Delivery