On this page
A standard chessboard is an 8 × 8 board of 64 equal squares, as Wolfram MathWorld describes it. Counting every size along its lines gives 204 squares and 1,296 rectangles. Here is how.
How many squares are there on a chessboard?
Count by size. A 1 × 1 square fits in 64 places. A 2 × 2 square's top-left corner can sit in 7 columns and 7 rows: 49 places. In general a k × k square fits in (9 − k)² places.
1 × 1: 64
2 × 2: 49
3 × 3: 36
4 × 4: 25
5 × 5: 16
6 × 6: 9
7 × 7: 4
8 × 8: 1
The total is 1² + 2² + … + 8² = 8 × 9 × 17 / 6 = 204, using the sum-of-squares formula n(n + 1)(2n + 1)/6. OEIS A000330 notes that these numbers count the squares with sides parallel to the axes formed from an n × n square.
How many rectangles are there on a chessboard?
Look at the lines instead of the cells. An 8 × 8 board is drawn with 9 vertical and 9 horizontal lines. Pick 2 vertical lines for the left and right edges and 2 horizontal lines for the top and bottom, and you get exactly one rectangle; every rectangle comes from exactly one such choice.
So a chessboard has 9C2 × 9C2 = 36 × 36 = 1,296 rectangles. OEIS A000537 lists 1,296 as the n = 8 value of (n(n + 1)/2)², which it describes as the number of rectangles in an n × n array of squares. Squares count as rectangles, so 1,296 − 204 = 1,092 of them are rectangles that are not squares.
It is the same move behind counting triangles, diagonals and lines from points in JEE questions.
Does the formula work on any grid?
Yes, with one change for squares. Take an m × n board with m rows, n columns and m ≤ n.
Rectangles: (m + 1)C2 × (n + 1)C2, which is m(m + 1)n(n + 1)/4. OEIS A096948 gives the same count, the product of two triangular numbers, for the rectangles in an n × m rectangle built from unit squares.
Squares: a k × k square fits in (m − k + 1)(n − k + 1) places, for k from 1 to m. Add these up; for m = n this is the sum of squares.
Worked example on a 3 × 5 board:
Rectangles: there are 4 horizontal lines and 6 vertical lines, so 4C2 × 6C2 = 6 × 15 = 90.
Squares of side 1: 3 × 5 = 15.
Squares of side 2: 2 × 4 = 8.
Squares of side 3: 1 × 3 = 3. No side-4 square fits.
Total squares: 15 + 8 + 3 = 26, so 90 − 26 = 64 rectangles are not squares.
What about tilted squares on a chessboard?
If a question counts squares with corners on the grid points, a square need not sit straight. On a 2 × 2 board, joining the midpoints of the four outer edges gives a tilted square of side √2.
OEIS A002415 counts these: an n × n grid of points holds n²(n² − 1)/12 squares, tilted ones included. Its own example for a 3 × 3 grid of points (a 2 × 2 board) finds four 1 × 1 squares, one √2 × √2 square and one 2 × 2 square, 6 in all. A chessboard has 9 × 9 grid points, so the formula gives 81 × 80 / 12 = 540 squares, of which 540 − 204 = 336 are tilted.
Why? Every grid square fits snugly inside an upright square of side s, one corner on each side. Each upright square holds s of them (s − 1 tilted plus itself) and has (9 − s)² places. Summing s(9 − s)² from s = 1 to 8 gives 64 + 98 + 108 + 100 + 80 + 54 + 28 + 8 = 540.
A 10-minute practice plan
Count the squares on a 4 × 4 board size by size, then check with the formula. (Answer: 30.)
Count its rectangles using lines. (Answer: 5C2 × 5C2 = 100.)
Do a 2 × 6 board both ways. (Answer: 17 squares, 63 rectangles.)
On a 3 × 3 grid of points, find all 6 squares, including the tilted one.
If choosing pairs of lines still feels shaky, read how to stop double counting in permutations and combinations next. For more practice, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



