Squares on a Chessboard How many squares on a chessboard? You might say 64 (8x8), but what about the big square round the outside & the myriad of 2x2, 3x3 ... 7x7 squares? This project animates a systematic counting process in such a way as to highlight a simple formula for it, being (1x1)+(2x2)+(3x3)+(4x4)+(5x5)+(6x6)+(7x7)+(8x8)
Created by @gregatku for use in Coding Classes for Kids Unlimited. This is a problem I normally teach in Maths Classes, but I thought my Coding students may like to see how we can use Code to solve tricky maths problems. Code is mine, similar to my solution to @papipupepappa's Chessboard Challenge 2 (https://scratch.mit.edu/projects/782216231/) which was more extensive than this in that you had to count how many rectangles on a chessboard not just the squares. I made a separate project (unshared) to draw the chessboard used in the backdrop, then saved the image as a PNG file and uploaded it to this project to form the backdrop for it. For those of you with a keen eye, you may have noticed that my Chessboard backdrop has changed since I first shared this project. I realised that it was incorrectly oriented, in that the top left corner was a black (brown) square, when it should have been a white one. So I edited the code in my unshared board drawing project, to create a new version of the backdrop in the correct orientation. Of course it makes no real difference in this project, since we're not actually playing Chess, just counting how many squares there are. By the way, for the mathematically inclined there is a much simpler way to calculate how many squares there are in an N x N square lattice, namely: ( (N x (N+1) x (2N + 1) ) / 6 For a chessboard that's (8 x 9 x 17) / 6 = 204 ! More generally in mathematics this is known as the Sum of Squares formula, and the "How many squares on a Chessboard" question is just the sum of the squares from 1 to n, where for a Chessboard n = 8. There is lots of information about the Sum of Squares on the Internet if you take the time to look for it, with a major focus being around proofs that the formula above is correct. The most common of these is the Proof by Induction, where you assume the Hypothesis is correct, and add another term to it "(n+1) squared", then show by rearrangement of the formula plus the extra term, is actually of the same form for n+1 as it is for n, then all you need to do is show it's true for one case (eg, the easiest one where n=1), and that proves that it's true for all values of n. The problem with Induction proofs is that you have to know what the "formula" is before you start, and that raises the question, "Well how did some mathematician come up with the formula in the first place?" Many of these can also be found, by different famous mathematicians of the past, but they are very detailed. More interesting to me is the wide range of Visual Proofs, perhaps the most interesting of which was the one where if you form a square pyramidal stack, with a corner being the common point in all layers from 1 x 1 down to some arbitrary n x n, and then create 6 copies of it. Those 6 copies can be clicked together to form a cuboid with the dimensions: n, n+1 & 2n+1 the volume of which is n x (n+1) x (2n + 1), and since there are 6 identical stacks comprising that cuboid, dividing that by 6 gives you the volume of one of them and thereby the Sum of Squares formula. I have implemented another of the interesting "Visual Proofs" in this Project: