The X+Y Files

Issue 4

How Many?

How many squares are there in this diagram?

The quick answer is 16, but this does not include squares of all sizes.

The total number of squares is
1 + 4 + 9 + 16 = 30.

It follows that in an n × n square grid there are 1 + 2² + 3² + ... n².

[There is a formula for this sum:
1/6n(n + 1)(2n + 1)]

In this triangular grid the total number of triangles is 16 + 7 + 3 + 1 = 27

The problem is more complicated because the triangles can appear two ways up –  and .

The number of s = 10 + 6 + 3 + 1 = 20

The number of s = 6 + 1 = 7

Both these totals are sums of triangular numbers. There is a formula for the sum of the first n triangular numbers, and hence for the number of s.

1 + 3 + 6 + 10 + … + 1/2n(n + 1) = 1/6n(n + 1)(n + 2) 

However, the number of s depends on whether n is odd or even.