A Magic square is an array of consecutive integers (from 1 to n2) arranged in a square, where each row, column and diagonal adds up to the same number.
Magic Square generation[]
Siamese Method[]
The common and easiest method to create a magic square is known as the Siamese Method, or De la Loubère method. It works for any odd-order magic square.
Start the "1" placed in the middle of the top row. Move up and right one cell, wrapping around to the bottom and left as necessary, with each cell providing the next digit. If the next cell is already filled by a prior number, instead move down one cell for the next digit.
Brute force search[]
The least efficient method, but can be sped up if done in the correct order. It works for any square that isn't too large, and can be adapted if looking for any random square.
If choosing this method, it seems best to start with the top row, and the two main diagonals.
External links[]
| This article is a stub. You can help Math Wiki by expanding it. |