HomeGuidesMath puzzles
Math puzzles · Practical guide

Count Rectangles in a Grid: Formula and 6 Answered Puzzles

A grid with 2 rows and 3 columns contains 18 rectangles of all sizes, including squares. Counting only its six small cells misses rectangles that span several cells. Choose grid-line boundaries or count each possible size to find the total.

The useful takeaway

For r rows and c columns, choose two of the r + 1 horizontal lines and two of the c + 1 vertical lines. The total is r(r + 1)c(c + 1) ÷ 4, including squares.

Decide which shapes count

This guide uses a complete rectangular grid with sides on its horizontal and vertical grid lines. Squares count as rectangles. Tilted shapes and diagonals do not count, and there are no missing cells or broken lines.

Rows and columns describe the cells, not the boundary lines. Two rows have three horizontal lines; three columns have four vertical lines. The outer border counts too.

Choose boundaries to get 18 rectangles in a 2-by-3 grid

Each rectangle needs a top and bottom boundary. From three horizontal lines, the possible pairs are first–second, first–third and second–third: 3 choices. From four vertical lines, there are 6 choices for the left and right boundaries.

Two rows and three columns: choose two boundaries in each directionThree horizontal lines are labeled A, B, C. Four vertical lines are labeled 1, 2, 3, 4. The rectangle between horizontal lines A and B and vertical lines 1 and 3 is shaded as one example; larger and smaller rectangles also count.1234ABC
The shaded 1-by-2 rectangle is just one of 18. Choose any two horizontal and any two vertical boundaries, including the outer border.

Every horizontal pair works with every vertical pair, so the total is 3 × 6 = 18. Each selection identifies exactly one rectangle. You are choosing unordered pairs of distinct lines: swapping “top” and “bottom” does not create another shape.

Check the answer by counting every size

Rectangles by size in a 2-row, 3-column grid
Height × width in cellsNumber of positions
1 × 16
1 × 24
1 × 32
2 × 13
2 × 22
2 × 31
Total18

A rectangle h cells high and w cells wide has (r − h + 1)(c − w + 1) possible positions. For example, a 1-by-2 rectangle fits in two horizontal positions in each of two rows: 2 × 2 = 4. Add all six size counts to confirm 18.

Apply the same formula to a larger complete grid

A grid with r rows has r + 1 horizontal boundaries. The number of pairs is r(r + 1) ÷ 2. Similarly, c columns provide c(c + 1) ÷ 2 vertical pairs. Multiplying gives r(r + 1)c(c + 1) ÷ 4.

For a 3-by-4 grid, the horizontal count is 3 × 4 ÷ 2 = 6 and the vertical count is 4 × 5 ÷ 2 = 10. Therefore it contains 60 rectangles. Use the pair counts before multiplying if the combined formula looks crowded.

Try six rectangle-counting questions

Count rectangles of every size, including squares, with sides on the grid lines. Each question uses a complete grid of square cells.

1. How many rectangles are in a 1-row, 1-column grid?

1. Two horizontal and two vertical lines each provide one pair. The single square is also a rectangle.

2. How many rectangles are in a 1-row, 4-column grid?

10. There is one horizontal pair and 5 × 4 ÷ 2 = 10 vertical pairs. Counting widths gives 4 + 3 + 2 + 1 = 10.

3. How many rectangles are in a 2-row, 2-column grid?

9. Three horizontal lines give three pairs, as do three vertical lines. The total is 3 × 3 = 9.

4. How many rectangles are in a 2-row, 3-column grid?

18. Multiply three horizontal pairs by six vertical pairs. The six small cells are only one size within the total.

5. How many rectangles are in a 3-row, 4-column grid?

60. Four horizontal lines give six pairs; five vertical lines give ten. Thus 6 × 10 = 60.

6. How many rectangles are in a 4-row, 5-column grid?

150. Five horizontal lines give ten pairs; six vertical lines give fifteen. Multiply 10 × 15 = 150.

Use the free challenge to check your method

The free Math Puzzle Challenge includes the 2-by-3 grid and an answer check. Solve it before opening the hint, then compare the explanation with your boundary pairs. These original website exercises are separate from Math Riddles app levels.

If you missed a constraint, use the puzzle strategy checklist. For another grid task, try missing-number puzzles; for the products, review mental multiplication shortcuts.

Common questions

Do squares count when counting rectangles?

Yes, under the rule used here. A square is a rectangle with equal side lengths. Read the question carefully if it excludes squares.

Does turning the grid sideways change the total?

No. Swapping rows and columns swaps the two pair counts without changing their product.

Can I use the formula on a grid with missing lines?

Not directly. The formula assumes every chosen pair of horizontal and vertical lines forms a complete rectangle.

Published by Moocsoft, the independent studio behind Math Riddles. Examples and worksheets are illustrative. App features can vary by platform and version; see the store listing for current availability and in-app purchases.

From this guide to your phone

Ready for a different kind of math riddle?

After the website grid exercises, explore Math Riddles for a separate collection of number and logic challenges, with hints, solutions and live 1v1 play. The original grid questions here are website practice, separate from app levels.

  1. Make your own attempt at a riddle.
  2. Use hints and solutions to review the intended reasoning.
  3. Try another challenge or invite a friend to a private battle.

Free to download, with ads and optional in-app purchases. Premium unlocks additional features; check your store for current availability. The examples in this guide are separate from app levels.

Explore Math Riddles features →
Take the next step

Get Math Riddles.

Solve handcrafted math riddles, play quick brain games and challenge friends in live 1v1.

Free to download · iPhone, iPad & Android · Ads and optional in-app purchases