I am trying to help my son with a fairly basic maths question for school.
How many squares are on a standard $8\times8$ chess board?
We have solved this one quickly, and then explored a number of different ways to calculate the answer in a number of different languages, all similar to the below:
$ \text{Size} = 8 $
$ \text{Squares} = \text{FOR } 1 \text{ TO Size: Squares} = \text{Squares} + \text{Size}^2 $
Is there a way to express this kind of loop as a mathematic equation? We've searched some texts at home and online, and got to this
$N=\sum_{s=1}^n s^2$
but I'm not confident this is correct.
I'm trying to count all of the squares of any size. Where $S = 8$ (the size of a chessboard) $N$ (the number of any size square) $= (8 \times 8)+(7 \times 7)+(6 \times 6)+(5 \times 5)+(4 \times 4)+(3 \times 3)+(2 \times 2)+(1 \times 1) = 204 $.
Size²squared? Are you trying to count all unit squares or all squares of any size? Because I don't think this counts either of those because your result appears to beSize^3. Are you trying to count the following? $$ \sum_{i=1}^8\sum_{j=1}^8 1 = \sum_{i=1}^{8} 8 = 8\cdot 8 = 8^2 $$ – Vepir Aug 23 '20 at 14:52Where S = 8 (the size of a chessboard)
N (the number of any size square) = (88)+(77)+(66)+(55)+(44)+(33)+(22)+(11) = 204
Thanks for the super-speedy response @Vepir !
– D10N-CB3 Aug 23 '20 at 14:58[set z=0, then do (FOR i=x TO y) { z = z + a(i) }, then return z.]would be the summation notation in mathematics:$$ \left(\sum_{i=x}^y a(i)\right) $$
Then for your problem, you can substitute: $a(i)=i^2$ and $x=1,y=8$.
P.S. The wolfram alpha recognizes the "sum" command.
– Vepir Aug 23 '20 at 15:08