Magic square
In recreational mathematics, a
magic square is an arrangement of distinct numbers, usually integers, in a square grid, where the numbers in each row, and in each column, and the numbers in the forward and backward main diagonals, all add up to the same number. A magic square has the same number of rows as it has columns, and in conventional math notation, "
n" stands for the number of rows it has. Thus, a magic square always contains
n2 numbers, and its size is described as being "of order
n". A magic square that contains the integers from 1 to
n2 is called a
normal magic square. It is possible to construct a normal magic square of any size except 2 × 2, although the solution to a magic square where
n = 1 is trivial, since it consists simply of a single cell containing the number 1. The smallest nontrivial case, shown below, is a 3 × 3 grid. The constant that is the sum of every row, column and diagonal is called the magic constant or magic sum,
M.