- 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.
| n | Size 1 | Size 2 | Size 3 | Size 4 | Total |
|---|---|---|---|---|---|
| 2 | 4 | 1 | - | - | 5 |
| 3 | 9 | 4 | 1 | - | 14 |
| 4 | 16 | 9 | 4 | 1 | 30 |
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.
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. How many squares of all sizes are there in a 3 by 3 grid?
- 9
- 10
- 13
- 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. In a 4 by 4 grid, how many squares have a side of 2 cells?
- 8
- 9
- 12
- 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. How many squares of all sizes are there in a grid of 2 rows and 4 columns of cells?
- 8
- 9
- 10
- 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. How many squares of all sizes are there in a 5 by 5 grid?
- 50
- 55
- 60
- 75
Show answer
Answer: B. Add the squares: 25 + 16 + 9 + 4 + 1 = 55.
-
5. How many squares of all sizes are there in a 4 by 4 grid?
- 20
- 26
- 30
- 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.