# How many squares are in the chessboard?

How to determine the numbers of squares in not only in chess board but also in a square figure like the chess. I need a general formula.

WHat I guess Is, I have 9 lines in both side so I can have $9C2 \times 9C 2$? • What do you mean with you needing a general formula? You mean to ask how many squares are in a $n\times n$ board? Observation: this chess board needs to be rotated $90º$. Sep 25, 2013 at 21:23
• @Git Gud: Unless the opponents are seated east and west! Sep 25, 2013 at 21:28
• @bluesh34 Indeed. Sep 25, 2013 at 21:29
• Your $\binom92^2$ will count a lot of rectangles too.
– mrf
Sep 25, 2013 at 21:29
• This well-known problem corresponds with summing entries of a multiplication table. If you just want subsquares, then sum up the square entries. If you want all possible subrectangles, convert the board to an 8x8 multiplication table and sum all the entries. Sep 25, 2013 at 21:52

What you look for is probably $\sum_{k=1}^nk^2=\frac{n(n+1)(2n+1)}{6}$, so for $n=8$ it's $204$.

• all of the squares are allowed, so i guess answer will be more. Sep 25, 2013 at 21:29
• @mathphy: On the board, there is 1 8x8 square, 4 7x7 squares, 9 6x6, and so on. Do you see why? (Hint, slide them around mentally to see where they may be). Sep 25, 2013 at 21:35

You are correct that for an $n \times n$ chessboard you can choose the two rows in ${n+1\choose 2}$ ways, but then the vertical rows must be chosen to be the correct distance apart. An easier way to get the count is to note that for an $i \times i$ square, you can set the left side in $n-i+1$ places and the top side in $n-i+1$ places. So the total is $\sum_{i=1}^n (9-i)^2=\sum_{i=1}^n i^2=\frac {n\cdot (n+1) \cdot (2n+1)}6$, which for $n=8$ is $204$

Consider the following method for an $n\times n$ chessboard:

• Choose $1\times 1$ squares: there are obviously $n^2$ such squares.
• Choose $2\times 2$ squares: there are $(n - 1)^2$ such squares, because you have one less degree of freedom on each axis.
• Choose $3\times 3$ squares: there are $(n - 2)^2$ such squares, because you have two less degrees of freedom on each axis.
• And so on.

These are all mutually exclusive so you do not overcount any squares, and so the result is $$n^2 + (n-1)^2 + \cdots + 2^2 + 1^2,$$ which has a well known formula. For your case, it's 204.

No. It's harder I think. If you do it the way you said, I mean you choose $2$ lines from $9$ lines to form a row and a column then you're counting the number of rectangles in a chess board.

How about $1^2+2^2+\cdots+8^2$?

• If i'm asked to find out rectangle? Sep 25, 2013 at 21:32
• @mathphy: If you're asked to find out the rectangles then you're on the right track I believe, except that the first horizontal and vertical lines in the chessboard shouldn't be counted because they don't form anything I think. Sep 25, 2013 at 21:35
• Yes, if you are finding rectangles it is \${n+1 \choose 2}^2. You can choose any two of the vertical lines, including the edges of the board, and any two of the horizontal lines. Sep 25, 2013 at 21:36
• You have to choose two different lines. So choose two more, one horizontal and one vertical, and see if the area is zero. Sep 25, 2013 at 21:45
• No, you still have two more lines to pick-the bottom and the right of the rectangle. You have to pick two in each direction. As long as you don't pick the same one twice, the area will be greater than zero. Sep 25, 2013 at 21:58

General agreement I see! However, if I regard the chessboard as a 9x9 grid of lines, do the points (1,0), (9,1), (8,9) and (0,8) not form a square?? And indeed the points (1,0), (2,1),(1,2),(0,1),....

Counting like this there are 540 squares (n different squares using the outer lines of each nxn subgrid - each such subgrid can be positioned in (9-n)x(9-n) locations).

To the person who deleted this answer: the answer I have provided is 540, or 1x8x8 + 2x7x7 + 3x6x6 + 4x5x5 + 5x4x4 + 6x3x3 + 7x2x2 + 8x1x1.

As a further clarification - the question is "How many squares are in a chessboard". The additional, diagonally oriented squares I have mentioned, which none of the previous answers refer to, are certainly "in" the chessboard.

I am happy for my answer to be debated mathematically, but not binned by a bureaucrat!

$$\sum_{i=0}^n (n-i)*(i+1)^2 = \frac{n(n+1)^2(n+2)}{12}$$

The formula.

• Hi, welcome on the MathSE! Good that you know latex, however the syntax is a little bit different. I fixed your post, but it is not enough. Please extend your answer by explaining, why is this the formula and how it comes out. There is a review mechanism here and these answers without a simple formula are likely deleted on the end. Jun 25, 2018 at 4:28