• Foundation
  • About 11 min
  • 5 practice questions

Counting squares in a grid

Count squares of every size in a square grid by size, and use the sum of squares pattern for larger grids.

If something looks wrong, please tell us.

A chessboard has 64 small squares, but if you count squares of all sizes you get many more. In a grid question the easy mistake is to count only the smallest squares. The method is to count squares size by size.

Count by size

In an n by n grid of small squares, the number of squares with side k (in cells) is (n minus k plus 1) times (n minus k plus 1), since the square can start in that many columns and rows. Add up all sizes from 1 to n.

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

The totals are 1, 5, 14, 30 for n equal to 1, 2, 3, 4. In general the total is 1 squared plus 2 squared, and so on up to n squared. For n equal to 5 it is 1 plus 4 plus 9 plus 16 plus 25, which is 55.

Worked examples

Example 1. How many squares are in a 4 by 4 grid? Working: size 1 gives 16, size 2 gives 3 times 3, which is 9, size 3 gives 2 times 2, which is 4, size 4 gives 1. Total 16 plus 9 plus 4 plus 1. Answer: 30.

Example 2. How many squares in a 5 by 5 grid? Working: 25 plus 16 plus 9 plus 4 plus 1. Answer: 55.

Example 3. A 3 by 5 grid of cells (3 rows, 5 columns): how many squares? Working: size 1 gives 3 times 5, which is 15. Size 2 gives 2 times 4, which is 8. Size 3 gives 1 times 3, which is 3. No larger squares fit since there are only 3 rows. Total 15 plus 8 plus 3. Answer: 26.

Squares in an n by n grid: 1 squared plus 2 squared plus ... plus n squared. For n = 1, 2, 3, 4, 5 the totals are 1, 5, 14, 30, 55.

— Pattern to remember

Key takeaways: count by size; the number of squares of a given size is (n minus k plus 1) squared; the total follows the sum of squares.

Check your understanding

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

    1. 9
    2. 10
    3. 13
    4. 14
    Show answer

    Answer: D. Count by size: 9 of side 1, 2 x 2 = 4 of side 2, and 1 of side 3. Total 9 + 4 + 1 = 14.

  2. 2. In a 4 by 4 grid, how many squares have a side of 2 cells?

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

    Answer: B. A square of side k fits in (n - k + 1) positions across and down. Here 4 - 2 + 1 = 3, so 3 x 3 = 9.

  3. 3. How many squares of all sizes are there in a grid of 2 rows and 4 columns of cells?

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

    Answer: D. Size 1: 2 x 4 = 8. Size 2: 1 x 3 = 3. No larger square fits in 2 rows. Total 8 + 3 = 11.

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

    1. 50
    2. 55
    3. 60
    4. 75
    Show answer

    Answer: B. Add the squares: 25 + 16 + 9 + 4 + 1 = 55.

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

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

    Answer: C. Size 1: 16. Size 2: 3 x 3 = 9. Size 3: 2 x 2 = 4. Size 4: 1. Total 16 + 9 + 4 + 1 = 30.

Sign in to keep track of the lessons you finish.

Next lesson → Counting rectangles in a grid

Privacy · Terms · Refunds · Delivery