Can a 4 by 4 magic square
be completed with the numbers 1 through 16 for entries?
I first need to determine my target sum.
The sum of all the values 1 through 16 is 136. Dividing this result
gives 34, which is my target sum for each row, column, and diagonal.
I then make an array of the numbers 1
Examining the sums, I find that only
the sums of the diagonals are 34:
I try to balance the results by inverting
the second and fourth rows:
This action changed the sums of the diagonals,
but it yields a sum of 34 for all columns:
I need to balance my rows. I notice that
the sums of the rows progressively increase from the first to
the fourth. All of the lower values are in the first two rows,
so I try balancing by inverting the second and third columns:
The result is now that everything but
the diagonals add up to 34:
So I need to focus on the diagonals:
The sum of the first diagonal is 38 (over
by 4) and the sum of the second is 30 (under by 4). I look for
values that I can substitute into both diagonals but that will
not affect the results of the rows and columns.
In the second row, I have 11 and 8 -
a difference of 3 - and 8 is currently in the first diagonal.
If I can switch the 8 and the 11, I can reduce the sum of the
first diagonal from 38 to 35.
In the third row, I have 9 and 6 - difference
of 3 - and 6 is currently in the second diagonal. If I can switch
the 6 and the 9, I can increase the sum of the second diagonal
from 30 to 33.
The sum of 11 and 6 (which are both in
the first column) is 17, and the sum of 8 and 9 (which are both
in the third column) is also 17. I can then replace the 11 and
6 into the third column and the 8 and 9 into the first column
without affect the sums of those columns:
So I now have:
So I need to reduce the sum of the first
diagonal by 1 and increase the sum of the second by 1.
By examining the array, I see that I
can exchange the 10 and 7 from the second column with the 11 and
6 in the first:
And the result is a 4x4 magic square: