Magic squares have become popular with the invention of math-based games like Sudoku. A magic square is an arrangement of numbers in a square such that the sum of each row, column, and diagonal equals a fixed number, called the "magic constant". This article will tell you how to solve all kinds of magic squares, both odd order, even order not multiple of four, or even order multiple of four.
Step
Method 1 of 3: Solving Magic Squares of Odd Order
Step 1. Calculate the magic constant
You can find this number by using a simple mathematical formula, where n = the number of rows or columns in the magic square. For example, for a 3x3 magic square, then n = 3. Magic constant = [n * (n * n + 1)] / 2. So in the example with a 3x3 square:
- Sum = [3*(3*3+1)]/2
- Sum = [3 * (9 + 1)] / 2
- Quantity = (3 * 10) / 2
- Quantity = 30 / 2
- The magic constant for a 3x3 magic square is 30/2, which is 15.
- All rows, columns, and diagonals must add up to this number.
Step 2. Place the number 1 in the middle square on the top row
This is where you always start for odd-order magic squares, no matter how big or small the magic squares are. So, if you have a 3x3 magic square, place 1 in square 2 (second square from the left, or right). Another example, for a 15x15 magic square, place the number 1 in square 8 (the eighth square from the left or right).
Step 3. Fill in the remaining numbers using the "one square up, one square right" pattern
You will always enter the numbers sequentially (1, 2, 3, 4, and so on) by moving up one row, then right one column. Soon you'll notice that to place the number 2, you'll move past the top row, out of the magic square. It doesn't matter, because even though you always fill in numbers in a way to the top of one square, to the right of this one box, there are three exceptions that also have patterned and predictable rules:
- If the movement of the number filling leads you to a box that passes through the top row of the magic square, then stay in the column of that square, but place the number in the bottom row of that column.
- If the movement of the numbering leads you to a box that passes through the rightmost column of the magic square, then stay in the row of that square, but place the numbers in the leftmost column of that row.
- If the movement of filling numbers makes you go to a box that has been filled, then return to the previous box that has been filled, and place the next number under that box.
Method 2 of 3: Solving Magic Squares of Even Order Not Multiples of Four
Step 1. Understand what is meant by a magic square of an even order not a multiple of four
Everyone knows that even numbers are divisible by two, but in magic squares, there are different methodologies for solving even-order squares that are not multiples of four (singly even magic square) and those that are multiples of four (doubly even magic square).
- Even-order squares that are not multiples of four have a number of squares on each side that are divisible by two, but not divisible by four.
- Even-order magic squares that are not multiples of four are the smallest is 6x6, because 2x2 magic squares cannot be made.
Step 2. Calculate the magic constant
Use the same method as you would with an odd-order magic square: the magic constant = [n * (n * n + 1)] / 2, where n = the number of squares on each side. So, in the example of a 6x6 magic square:
- Sum = [6*(6*6+1)]/2
- Sum = [6 * (36 + 1)] / 2
- Quantity = (6 * 37) / 2
- Quantity = 222 / 2
- The magic constant for a 6x6 magic square is 222/2, which is 111.
- All rows, columns, and diagonals must add up to this number.
Step 3. Divide the magic square into four equal-sized quadrants
Mark them with A (top left), C (top right), D (bottom left) and B (bottom right). To find out how large each quadrant should be, simply divide the number of squares in each row or column by two.
So for a 6x6 square, the size of each quadrant is 3x3 squares
Step 4. Give each quadrant a range of numbers
Quadrant A gets a quarter of the first numbers, quadrant B is a quarter of the second numbers, quadrant C is a quarter of the third numbers, and quadrant D is the last quarter of the total range of numbers for a 6x6 magic square.
In the 6x6 square example, quadrant A will be numbered from 1 to 9, quadrant B with 10 through 18, quadrant C with 19 to 27, and quadrant D with 28 to 36
Step 5. Solve each quadrant using the methodology for odd-order magic squares
Quadrant A will be easy to fill, because it starts with the number 1, just like a magic square in general. But for quadrants B to D, we'll start with the unusual numbers 10, 19 and 28, for this example.
- Think of the first number in each quadrant as if it were one. Place it in the center box on the top row of each quadrant.
- Think of each quadrant as if it were its own magic square. Even if a box is in an adjacent quadrant, ignore the box and proceed according to the "exception" rule appropriate to the situation.
Step 6. Create Highlights A and D
If you try to add up the columns, rows, and diagonals at this point, you'll notice that they don't equal the magic constant yet. You'll need to swap a few squares between the top left and bottom left quadrants to complete the magic square. We will refer to these swapped areas as Highlights A and Highlights D. (Notes:
the explanations in this and the next step are more specific to 6x6 magic squares, which may not be suitable for larger magic squares).
- Using a pencil, mark all the boxes on the top row until you reach the median box position of quadrant A. (Note: The median can be found from the formula n = (4 * m) + 2, with m as the median). So, in a 6x6 square, you would mark only square 1 (which contains the number 8 in the box), but in a 10x10 square, you would mark squares 1 and 2 (which contain the numbers 17 and 24 in both squares, respectively).).
- Mark an area as a square using the boxes that have been marked as the top row. If you mark only one box, then your square is only that one box. We will refer to this area as Highlight A-1.
- So, for a 10x10 magic square, Highlight A-1 would consist of squares 1 and 2 in rows 1 and 2, making up a 2x2 square in the top left of the quadrant.
- In the row below Highlight A-1, skip the squares in the first column, then mark the squares in the center of the quadrant. We'll call this middle row Highlight A-2.
- Highlight A-3 is a square identical to A-1, but in the lower left corner of the quadrant.
- Highlights A-1, A-2, and A-3 together form Highlight A.
- Repeat this process in quadrant D, creating identical highlight areas referred to as D Highlights.
Step 7. Swap Highlights A and D
This is one exchange after another. Move and alternate the boxes between quadrant A and quadrant D without changing the order at all (see figure). When you've done that, all the rows, columns and diagonals in the magic square should add up to the magic constant you calculated.
Method 3 of 3: Solving Magic Squares of Even Order Multiples of Four
Step 1. Understand what is meant by a magic square of an even order multiple of four
An even-order magic square that is not a multiple of four has a number of squares on each side that are divisible by two, but not divisible by four. A magic square of even order multiples of four has the number of squares on each side that is divisible by four.
The smallest even-order multiple of four that can be made is 4x4
Step 2. Calculate the magic constant
Use the same method as you would with an odd-order magic square: the magic constant = [n * (n * n + 1)] / 2, where n = the number of squares on each side. So, in the example of a 4x4 magic square:
- Sum = [4*(4*4+1)]/2
- Sum = [4 * (16 + 1)] / 2
- Quantity = (4 * 17) / 2
- Quantity = 68 / 2
- The magic constant for a 4x4 magic square is 68/2, which is 34.
- All rows, columns, and diagonals must add up to this number.
Step 3. Create Highlights A to D
At each corner of the magic square, mark a mini square with side length n/4, where n = side length of the magic square. Label with Highlights A, B, C, and D counterclockwise.
- In a 4x4 square, you will only mark the four corners of the square.
- In an 8x8 square, each Highlight will be a 2x2 area in its corner.
- In a 12x12 square, each Highlight will be a 3x3 area in its corner, and so on.
Step 4. Create a Center Highlight
Mark all the squares in the center of the magic square in the square area of length n/2, where n = side length of the magic square. The Center Highlights should not hit Highlights A through D at all, but only intersect with each of them in the corner.
- In a 4x4 square, the Center Highlight will be a 2x2 area in the center.
- In an 8x8 square, the Center Highlight will be the 4x4 area in the center, and so on.
Step 5. Fill in the magic square, but only in the highlighted areas
Start filling in the number in the magic square from left to right, but enter the number only if the square is in the Highlight box. So, for a 4x4 square, you would fill in the following boxes:
- Number 1 in the top left box and 4 in the top right box.
- Numbers 6 and 7 in the middle squares of the second row.
- The numbers 10 and 11 are in the middle squares of the third row.
- The number is 13 in the lower left box and 16 in the lower right box.
Step 6. Fill in the remaining squares of the magic square in reverse order of counting
This step is basically the reverse of the previous step. Start again from the top left box, but this time skip all the boxes in the highlighted area, and fill in the unhighlighted boxes in reverse counting order. Start with the largest number in your range. So, for a 4x4 magic square, you would fill in the following boxes:
- The numbers 15 and 14 are in the middle squares of the first row.
- The number 12 in the leftmost square and 9 in the rightmost square in the second row.
- Numbers 8 in the leftmost square and 5 in the rightmost square in the third row.
- Numbers 3 and 2 in the middle squares of the fourth row.
- At this point, all the columns, rows, and diagonals should add up to the magic constant you've calculated.