Bimagic squares of primes

In 1900, Henry E. Dudeney was probably the first to study magic squares of primes: below see a brief history. In 2005, among the 10 open problems of my Mathematical Intelligencer article, I asked this one:

Bimagic means a magic square remaining magic after each of its numbers have been squared. As a first step, in the Supplement of this article, I gave this CB16 square which was previously constructed in October 2004, as mentioned in the Puzzle 287 of Carlos Rivera asking the same problem. It is only a "semi"-bimagic square, meaning that the 2 diagonals were not bimagic.

In November 2006, I was happy to construct the first known bimagic square of primes. Fully bimagic, with its two diagonals bimagic. The Open problem 4 is the first solved problem on the ten! In this 11th-order square, 121 consecutive prime integers <= 701 are used, only excluding 2, 3, 523, 641, 677.

Here are the 6 main steps of the method used:

  1. Choose the order. My idea -for the supplemental beauty- was to have a prime order. 2 and 3 are impossible. 5, nobody knows a bimagic square using any set of numbers. 7, probably yet too small to have a sufficient number of bimagic series. 11, hmmm.
  2. Select carefully a good set of 121 prime numbers, using some modulo reasoning.
  3. With this set, compute the S1 and S2 sums.
  4. Compute the list of bimagic series of 11 primes, from the selected set, having the good S1 and S2 sums.
  5. Using these series, with combinatoric algorithms, to find 22 series that we can cross and correctly organize, producing a semi-bimagic square.
  6. Close to being finished? No! As usual with magic squares, one of the most difficult, and sometimes impossible, steps: find TWO good diagonals by rearranging the cells of the semi-bimagic square. Most of the semi-bimagic squares cannot create a bimagic square: I needed several hundreds of squares before succeeding.

Thanks to Jaroslaw Wroblewski: he is the fastest person to publish my square. It was in his paper titled "Kwadraty bimagicze" published in the Polish magazine MMM = Magazyn Milosnikow Matematyki, issue 18.

Since the open problem 4 is solved, I propose now a new challenge, the goal being to find smaller squares:

We have above a 4x4 semi-bimagic square. Here is a 10x10 semi-bimagic square, using 100 consecutive primes <= 571, only excluding 2, 3, 5, 547 and 563. A very nearly bimagic square: 10 bimagic rows, 10 bimagic columns, 1 bimagic diagonal, the other diagonal being "only" magic. Who will construct a fully bimagic square of order 10, or of a smaller order?

June 11th, 2014, Jaroslaw Wroblewski constructed this incredible bimagic square of order 8. This is also a pandiagonal magic square, as Tarry's square.

He used this construction method:

with these parameters:

The 64 integers of the square are given by this formula, where xi = 0 or 1:

With the same set of (a, b, s, t), but with various (k, c, d), he later found 14 other solutions. Here is the list of Wroblewski's 15 bimagic squares of primes, order 8, sorted by their MaxNb. The above square is the solution #8 in this list.

Magic squares of primes, a brief history

As stated in his book Amusements in Mathematics, page 125, it seems that the first to discuss the problem of constructing magic squares with prime numbers was Henry Ernest Dudeney. It was in The Weekly Dispatch, 22nd July and 5th August 1900. Unfortunately, at that time, "1" was considered as a prime number. The magic sum 111 of his 3x3 square is the lowest possible, allowing "1".

Harry A. Sayles also studied magic squares with prime numbers, and was probably the first to publish the correct 3x3 square, not using 1, with the smallest possible magic sum 177. It was in 1918, in The Monist, page 142. Rudolph Ondrejka later found the same square, reported by Joseph M. Madachy in 1966 in Mathematics on Vacation, page 95 (book later republished with another title, Madachy's Mathematical Recreations).

In 1914, Charles D. Shuldham published, in The Monist, three interesting papers on magic squares of prime numbers with numerous examples of various orders, for example, this pandiagonal magic square, page 608:

André Gérardin, in Sphinx-Oedipe, published various magic squares of primes beginning in 1916. For example, he gives this interesting method using sums of squares.

We know now numerous magic squares of various orders, using only prime numbers. I particularly mention the numerous squares and cubes of Allan W. Johnson, Jr. published in different issues of the Journal of Recreational Mathematics, for example, this pandiagonal magic square.

We also have to mention the famous square of Harry L. Nelson, who won the $100 prize offered by Martin Gardner: produce a 3x3 square of consecutive primes. See his paper in the Journal of Recreational Mathematics, 1988, pages 214-216.

In 2004, I constructed the smallest and first known magic squares of squares of primes: look at the CB17 and CB18 squares of the Supplement. See also Puzzle 288 of Carlos Rivera.

In 2007, Jaroslaw Wroblewski and Hugo Pfoertner constructed the first known magic square of cubes of primes: look at their 42x42 magic square.

In 2008, Raanan Chermoni and Jaroslaw Wroblewski found the first known AP25, an arithmetic progression of 25 primes:

With this AP25, we can easily arrange its 25 terms and construct this 5x5 pandiagonal magic squares of BIG primes:

On the orders 3 and 4, we can construct magic squares of still bigger primes, using AP9 and AP16; status of the current search at

For example, with the biggest known AP9, computed in 2012 by Ken Davis and Paul Underwood:

we can construct a 3x3 magic square of primes where the biggest used integer is this prime of 1014 digits!

In 2013 and 2014, Jaroslaw Wrobleski, then Max Alekseyev, sent to Natalia Makarova (through these pandiagonal squares of consecutive primes. Max Alekseyev, previously author of a 4x4x4 multiplicative magic cube, announced that his square has the smallest possible magic sum (S=682775764735680) for such squares:

For more on prime magic squares, see:

Return to the home page