Magic Squares

A magic square is a square array of distinct numbers in which the numbers of each row, column and diagonal add up to the same value, called the magic constant. The size of each row is called the order (n) of the magic square. Numbers in the magic square range from 1 to n2. The earliest known magic square is of order 3, due to Lo Shu, an ancient Chinese.
The exact number of possible magic squares for a given order is still an unsolved mathematical problem. We do know, however, there is one magic square for orders 1 and 3, zero for order 2, 880 for order 4, 275305224 for order 5, and about 1.8E19 for order 6.

Construction

Magic squares of any order can be constructed using various methods. The simplest one for odd orders (2k+1) is due to Kraitchic, and is called the Siamese method. Magic squares of doubly even (4k) can be constructed using the Lozenge method described by J.H. Conway, and those of singly even order (4k+2) can be constructed by the Lux method. These methods are described in detail in a Mathworld article.
A Java applet is available to display magic squares of various order (up to 30 for screen display limits). The source code will eventually be available under the programming/Java section of this site.