I'd love to explain.
Let's start with an even square.
Yellow | Yellow | ||
Yellow | Yellow | ||
Yellow | Yellow | ||
Yellow | Yellow |
On each diagonal, we're starting with a corner, then we're moving 1 row down and 1 column down.
That means the number of squares on the diagonal is the number of rows/columns.
As you can see in the above example, a 4 by 4 square has 4 yellow tiles in each diagonal.
The first tile on the (first row first column).
The second tile on the (second row second column).
The third tile on the (third row third column).
The forth tile on the (forth row forth column).
Also notice that there are 2 diagonals, with each diagonal having the same number of squares as the row/column.
So a e by e square has 2e yellow squares.
Now let's look at an odd square.
Yellow | Yellow | |
Yellow | ||
Yellow | Yellow |
The same rule as before applies, where each diagonal has the same number as the number of rows/columns.
There are also 2 diagonals, but look at the center.
That yellow tile is shared by both diagonals, meaning we would've counted it twice in the equation 2e.
So we have to subtract 1 from it.
2e - 1
I hope this was helpful. :))
=^._.^=