Pandiagonal Magic Squares


In addition to the two main diagonals, each diagonal that wraps around at the edges of the square, sums to the magic constant:

Squares that are pandiagonal and associative are called ultramagic. Two special classes of pandiagonal squares are:

The sum of each 2x2 block, (including wrap-around), is equal to 4/n of the magic constant.
The numbers of each complementary pair are distant n/2 on diagonals.

where n is a doubly even order. See note.

Squares that are compact and complete are called most-perfect.


PandiagonalSquares makes these squares using the methods outlined below. MagicSquaresSODLS also makes pandiagonal and ultramagic squares for some orders.

Order5Special makes the 3600 order 5 pandiagonal magic squares.

Odd Order

Method I

The Siamese method. See "Demanding the square is panmagic" in math behind the Siamese method. This method does not work when the order is a multiple of 3.

Method II

Squares of order n = 3k, k = 3, 5, 7, ... can be made by Margossian's method. See under Symmetrical and pandiagonal squares, page 207, in "Mathematical Recreations and Essays".

Doubly-Even Order

Method I

Margossian's method.

Method II

Planck's "A-D method" from associative magic squares. The method is:

In the example below, (e E), (f F), ... represent complement pairs. The cells of one broken diagonal are shown in color.

The squares made by this method are complete.

There are 48 order 4 pandiagonal magic squares. These are TYPE I in the classification by Dudeney. See references. They are all most-perfect.

Singly-Even Order

There are no pandiagonal magic squares of singly-even order.
This was shown by A.H. Frost (1878) and C. Planck (1919). See references.


There are singly-even magic squares in which only four diagonals do not sum to the magic constant. PandiagonalSquares makes these squares using a process involving three main steps:

  1. Make a semi-magic 4k+2 square that is center symmetric except for the middle 2x2 block, using this process, (similar to Conway's LUX method):

    where, for example, L' is the symmetric complement of L.

    Possible patterns for n = 6, 10, 14, 18 are:

    Orders 6, 14, 22, 30, ... and 10, 18, 26, 34, ... have similar patterns, (differences shown in blue).

  2. Transform this square using Planck's "A-D method". This gives a semi-magic square with only four diagonals that do not have the magic sum.
  3. Move 1 or more row(s) and/or column(s) from one side to the opposite side to make the square magic.

Pandiagonal Transform

A pandiagonal magic square remains pandiagonally magic if a row or column is moved from one side of the square to the opposite side. So, each order n square makes a total of n2 squares in this way. A near-pandiagonal magic square can be transformed into (n-2)2 near-pandiagonal magic squares in this way, (and 4(n - 1) semi-magic squares).

Pandiagonal 1-Way

In addition to the two main diagonals, all the diagonals, (parallel to only 1 main diagonal), that wrap around at the edges of the square, each add up to the magic constant:

Odd Order

There are 77580 order 5 pandiagonal 1-way magic squares.

Here are order 7 and order 9 pandiagonal 1-way magic squares.

Singly-Even Order

There are no pandiagonal 1-way magic squares of singly-even order. See Planck's proof.

Doubly-Even Order

For doubly-even orders greater than 4, there are pandiagonal 1-way magic squares. Here are order 8, order 12 examples.

Pandiagonal Not Magic

There are squares in which all diagonals have the magic sum but the rows and columns may not. One example of these is made by simply writing the ordered sequence 1 to n2:

These are called natural squares. See Planck. See also reversible squares.


"Pandiagonal magic square"

Candy, Albert L. "Pandiagonal Magic Squares of Prime Order";view=1up;seq=7

Candy, Albert L. "Pandiagonal Magic Squares of Composite Order";view=1up;seq=5

Dudeney, Henry E. "Magic Square Problems"

Dudeney, Henry E. "Magic Square Problems"
, page 287.


Heinz, Harvey "Order 4 Magic Squares, Group I ...The pandiagonals" I

Heinz, Harvey "Ultra Magic squares - Walter Trump"

Hospel, Ton "The math behind the Siamese method of generating magic squares"


Rouse Ball, C.W. and H.S.M. Coxeter "MATHEMATICAL RECREATIONS AND ESSAYS, Thirteenth Edition"

Weisstein, Eric W. "Panmagic Square." From MathWorld--A Wolfram Web Resource.