TransWikia.com

How to denote a FOR...LOOP in mathematics

Mathematics Asked by user3190686 on February 3, 2021

I am trying to help my son with a fairly basic maths question for school.

How many squares are on a standard $8times8$ 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 $.

One Answer

A Recurrence relation is probably your best bet here: $$n_i = n_{i-1} + n^2$$ This explains it pretty well: here's an expansion of the first few terms: $$begin{align} n_1 &= 1 \ n_2 &= 1 + 4 = 5 \ n_3 &= 5 + 9 = 14 \ ... \ n_8 &= 140 + 64 = 204 end{align}$$

You can also use this direct formula for the sum of squares: $$n_i = frac{i(i+1)(2i+1)}{6}$$ This directly gives you $n_8 = frac{8 times 9 times 17}{6} = 204$

Answered by Aniruddha Deb on February 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP