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. The constant that is the sum of every row, column and diagonal is called the magic constant or magic sum.

Related formulas


MMagic constant (dimensionless)
nNumber of rows (and columns) (dimensionless)