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:

Open problem 4. Construct a bimagic square using distinct prime numbers.

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.

 29 293 641 227 277 659 73 181 643 101 337 109 241 137 139 673

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.

 137 131 317 47 5 457 541 359 467 353 683 401 277 239 647 23 421 229 181 7 419 653 463 269 701 59 157 257 563 557 179 191 101 593 311 379 503 197 83 53 521 149 619 89 307 617 397 241 571 661 109 107 79 127 281 373 443 29 587 383 61 19 409 631 389 173 73 11 607 433 613 577 263 97 227 313 283 43 599 151 199 509 487 223 163 293 691 139 673 37 113 271 193 31 601 431 331 337 479 67 233 103 439 499 251 547 659 491 41 167 367 569 461 71 347 211 349 13 643 17 449

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:

Construct bimagic squares of primes, for each order < 11.

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?

 277 7 283 383 541 103 167 293 71 457 449 19 127 229 389 151 503 31 311 373 269 173 367 571 233 467 53 23 263 163 61 199 569 463 139 313 347 239 11 241 131 379 83 271 487 47 401 461 41 281 521 439 37 79 181 227 101 211 479 307 149 509 359 191 331 13 107 419 431 73 97 409 337 257 43 443 157 89 193 557 137 197 353 29 179 397 523 317 433 17 491 251 67 109 59 421 223 499 349 113

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

 10413102601438193 12552954442285363 64858219275339011 69616564276909621 13721103289000213 10874533897093523 65198099109403231 67647104300475221 9918646092261563 14676991093832173 65352675784515641 67492527625362811 10258525926325783 12707531117397773 68660676472077661 65814107080170971 67991406116513851 66483377435734781 10927796281889593 12038260761833963 66021946140079451 66823257269799001 9249375736697753 15346261449395983 65867369464967041 66977833944911411 13051832933436403 11543804252657333 64188948919775201 70285834632473431 11082372957002003 11883684086721553 64999317008985881 67845886400892571 13522321188582863 11073315997510873 68307317696547901 66167465855700731 13862201022647083 9103856021076473 68461894371660311 66012889180588321 10059743825908433 12906313217815123 68801774205724531 64043429204153921 13367744513470453 11227892672623283 12698474157906643 11897163028187093 69471044561288341 63374158848590111 10729014181472243 12237042862251313 67792624016096501 66682159536152131 14531471378210893 8434585665512663 67638047340984091 66836736211264541 12853050833019053 11742586353074683 65668587364549691 67176616045328761

He used this construction method:

 k + at c + k + bs + bt d + k + as + bs c + d + k + as + at + bt c + k + as + bs + at k + as + bt c + d + k d + k + bs + at + bt k + as + bs c + k + as + at + bt d + k + at c + d + k + bs + bt c + k k + bs + at + bt c + d + k + as + bs + at d + k + as + bt c + d + k + as + at d + k + as + bs + bt c + k + bs k + at + bt d + k + bs + at c + d + k + bt k + as c + k + as + bs + at + bt c + d + k + bs d + k + at + bt c + k + as + at k + as + bs + bt d + k + as c + d + k + as + bs + at + bt k + bs + at c + k + bt d + k + bt c + d + k + bs + at k + as + bs + at + bt c + k + as c + d + k + as + bs + bt d + k + as + at c + k + at + bt k + bs d + k + as + bs + at + bt c + d + k + as k + bt c + k + bs + at c + d + k + at + bt d + k + bs c + k + as + bs + bt k + as + at c + k + as + bt k + as + bs + at c + d + k + bs + at + bt d + k k + bs + bt c + k + at d + k + as + at + bt c + d + k + as + bs c + k + bs + at + bt k c + d + k + as + bt d + k + as + bs + at k + as + at + bt c + k + as + bs d + k + bs + bt c + d + k + at

with these parameters:

• a = 93439
• b = 76751
• s = 8720021310
• t = 21174423270
• k = 8434585665512663
• c = 1823940260813120
• d = 54939573183077448

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

• 8434585665512663 + 1823940260813120*x1 + 54939573183077448*x2 + 814790071185090*x3 + 1978516935925530*x4 + 669270355563810*x5 + 1625158160395770*x6

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 solution #8 in this list.

Nicolas Rouanet in 2020

Nicolas Rouanet, France, is an engineer working at LATMOS, optical department. This "Laboratoire ATmosphères, Milieux, Observations Spatiales" (= Atmospheres, Environments, Space Observations Laboratory) is a joint research unit of CNRS + University of Versailles + Sorbonne University. From January to November 2018, he worked on bimagic squares of primes, orders from 5 to 25, and obtained these excellent results:

• orders 5, 6, 7: semi-bimagic squares (and with one bimagic diagonal for the order 7)
• orders 8 to 25: bimagic squares (excluding orders 12 and 14)

Here are two of these squares:

 17 787 199 503 751 617 379 211 947 103 809 131 263 227 827 641 823 607 59 127 173 137 977 521 449
 673 653 61 277 317 89 601 449 71 149 383 641 487 569 137 683 541 271 257 613 499 163 37 739 677 7 379 431 761 313 359 193 503 719 127 107 331 179 691 463 139 397 631 709 97 643 211 293 167 523 509 239 41 743 617 281 349 401 773 103 587 421 467 19

Huang Jianchao in 2019

From November 2018 to April 2020, independently of Nicolas Rouanet, Huang Jianchao constructed five bimagic squares of consecutive primes: orders 24, 25, 26, 27, 28. Huang Jianchao is a Chinese mathematics teacher, Nanyang Center School of China, Xiaoshan District, Hangzhou, Zhe Jiang Province.

Because Nicolas Rouanet and Huang Jianchao worked on two same orders, 24 and 25, we can compare characteristics of their squares:

 Nicolas Rouanet's bimagic squares #1using non-consecutive primes,but minimizing the biggest used prime Nicolas Rouanet's bimagic squares #2using non-consecutive primes,but minimizing S1 and S2 Huang Jianchao's bimagic squaresusing consecutive primes Order Set of primes S1 S2 Set of primes S1 S2 Set of primes S1 S2 24 5 to 4241 47 018 129 551 040 5 to 4253 47 016 129 534 552 283 to 4721 57 490 177 744 912 25 5 to 4657 53 823 162 896 257 5 to 4679 53819 162 859 729 1609 to 6827 103 855 488 411 113

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".

 67 1 43 13 37 61 31 73 7

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).

 71 5 101 89 59 29 17 113 47

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:

 73 41 13 113 23 103 83 31 107 7 47 79 37 89 97 17

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.

 3² 5² 7² 37² + 2² 8² 52² 58² = 13 89 2753 4733 37² 7² 5² 3² 52² 58² 2² 8² 4073 3413 29 73 5² 3² 37² 7² 58² 52² 8² 2² 3389 2713 1433 53 7² 37² 3² 5² 8² 2² 58² 52² 113 1373 3373 2729

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.

 41 109 31 59 37 53 47 103 89 61 79 11 73 17 83 67

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.

 1480028201 1480028129 1480028183 1480028153 1480028171 1480028189 1480028159 1480028213 1480028141

In 2004, I constructed the smallest and first known magic squares of squares of primes: look at the CB17 (4x4) and CB18 (5x5) 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:

6171054912832631 + 366384*23#*n, for n = 0 to 24
(the notation 23# means 2*3*5*7*11*13*17*19*23 = 223092870)

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

 6171054912832631 6743218519407191 7315382125981751 7478857442145911 8051021048720471 7070169151735511 7642332758310071 7805808074474231 6334530228996791 6906693835571351 7969283390638391 6498005545160951 6661480861325111 7233644467899671 7397119784063831 6824956177489271 6988431493653431 7560595100227991 8132758706802551 6252792570914711 7724070416392151 7887545732556311 6416267887078871 6579743203243031 7151906809817591

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 http://users.cybercity.dk/~dsl522332/math/aprecords.htm

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

(65502205462 + 6317280828*n)*2371# + 1, for n = 0 to 8

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

6528 1797806551 4223969026 9465606678 8430413319 5255367568 8539223625 1894181816 2295567702 4019319671 9333832115 0061841041 7707195791 2803140095 8352804788 0185757536 6154874648 2856691539 8087025088 4358010975 5464536678 5697944644 8414005984 6147638197 4705147888 5491138440 0220327868 7363977428 2737801931 0520928772 5273502621 1160921647 5304393339 1767016703 7815224345 8891520911 6236415078 7937941027 3482586307 9771751835 2416069216 0455877228 7165528915 4691222310 5931802968 4750663643 9321249501 1529753060 2177270003 6356499195 3633416904 8702177467 8208223768 2956050987 5838438258 6851826872 9197546602 0234999349 2497621917 2738581161 9415122224 0117864207 4840555878 0205737919 5478023001 3058669932 0674106178 5760186912 4008237951 0383731554 0581804537 9660820190 6498476783 7685256998 6181217269 0236312263 0511714243 8492521158 0685298127 3315053479 1728430089 8633989547 0948111232 3941740735 3710609506 4479145195 2658117032 6376052349 8051287376 8947506973 0311459443 4926045579 0413748638 7963946563 1310017137 7738751714 9720291376 3358218759 4500584427 7708805850 0049908410 1090288421

In 2013 and 2014, Jaroslaw Wrobleski, then Max Alekseyev, sent to Natalia Makarova (through http://dxdy.ru/post751928.html#p751928) 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: http://oeis.org/A245721.

 320572022166380833 320572022166380921 320572022166380849 320572022166380917 320572022166380909 320572022166380857 320572022166380893 320572022166380861 320572022166380911 320572022166380843 320572022166380927 320572022166380839 320572022166380867 320572022166380899 320572022166380851 320572022166380903
 170693941183817 170693941183933 170693941183949 170693941183981 170693941183979 170693941183951 170693941183847 170693941183903 170693941183891 170693941183859 170693941184023 170693941183907 170693941183993 170693941183937 170693941183861 170693941183889

In 2018, 14 years after my magic squares of squares of prime numbers, orders 4 and 5, Nicolas Rouanet constructed magic squares of orders 6, 7, 8. Look also at his BImagic square of order 8.

• Download the 3 magic squares of squares of prime numbers by Rouanet (Excel file, 134Kb)
•  101² 73² 37² 107² 61² 131² 113² 127² 29² 139² 7² 11² 149² 17² 97² 31² 109² 67² 41² 53² 79² 71² 83² 163² 47² 157² 59² 103² 89² 19² 13² 5² 167² 43² 137² 23²

For more on prime magic squares, see: