Squares in a square
From Wikipedia, the free encyclopedia
In mathematics, a common mathematical puzzle involves finding the number of squares in a large n by n square grid. This number can be derived as follows:
- The number of 1x1 boxes found in the grid is n2.
- The number of 2x2 boxes found in the grid is (n − 1)2. These can be counted by counting all of the possible upper-left corners of 2x2 boxes.
- The number of kxk boxes (1 =< k =< n) found in the grid is (n − k + 1)2). These can be counted by counting all of the possible upper-left corners of kxk boxes.
It follows that the number of squares in a n by n square grid is:
or:
- x = n(n + 1)(2n + 1) / 6