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$?
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$?
Consider the following method for an $n\times n$ chessboard:
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.
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$.
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$
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$?
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.