The URL of this page is http://www.bigfoot.com/~robert.bak/magic.html
Last modified 18 December 2000

Magic Squares

Magic squares are a strange beast — they exist at all sizes except 2x2; it is not possible to construct a 2x2 magic square, unless one cheats and uses four numbers which are the same, instead of four different numbers.

A 1x1 magic square is possible, but a bit boring; just a single square with a number in it.  Magic squares proper start with the 3x3, of which the one shown below is the only possible example, barring rotations, reflections and alterations in the sequence used:

[3x3 magic square]

From order 4 and upwards, the numbers explode; I seem to recall that there are 88 order-4 squares (certainly there are dozens), hundreds of order-5 squares, and an unknown number (possibly thousands) of order-6 squares.

Join in the fun!

It is believed (I don’t know if it’s been proved) that magic squares of all orders (greater than 2) are possible.  Certainly a simple algorithm will give one a magic square of any odd order required:
  1. Start by placing your first number (traditionally 1) in the middle of the top row.
  2. At each step, move one cell up and one to the right.  If in doing so, one moves off the top row (as happens immediately at the start), wrap around to the bottom row; if one moves off the right column, wrap around to the left column.
  3. If the square one wishes to use next is already full, or one moves off the top-right cell, place the next number in the cell directly below the last cell used (this cell will always be empty).

If you desire a magic square of order xy, where x and y are both orders of magic squares which you know how to construct, the algorithm is even simpler:

  1. Divide your series of (xy)2 numbers into x2 sub-series of y2 numbers each.
  2. Make each of these sub-series into a magic square of order y.
  3. Assemble these squares into a meta-square of order x.

To demonstrate what I mean, there follows a 12x12 square composed of 9 4x4 squares on the pattern of the 3x3 square shown earlier:

[12x12 magic square]

Copyright © 2000 Robert J. Baker.  All rights reserved worldwide.