Problems & Puzzles: Puzzles

Puzzle 931. Twin primes 4x4 magic square.

Fran Rubin poses the following nice puzzle:

Q. Find a magic 4x4 square composed by 8 pairs of twin primes, such that the magic sum is minimal, or prove that such objects do not exist.


Contributions came from Simon Cavegn, Emmanuel Vantieghem and Adam Stinchcombe,


Simon wrote on Nov 11, 2018:

Found 48 solutions with sum 258 (without symmetries)
I guess 258 is the smallest possible sum, but not sure.
Also not sure if there are more than 48 Solutions.
For each of the 495 ways to take 8 of 12 first twin prime pairs:
Order the numbers accoring to all 880 possible simple 4x4 squares and test the sums.
S: Amount of correct 2x2 sub square sums of: (9*sub squares and 1*corners)
P: Amount of correct pandiagonals (max 6, not including normal diagonals)
SQ: The 4x4 magic square
S:8, P:2, SQ: 5,61,41,151,43,149,7,59,139,29,73,17,71,19,137,31
S:8, P:2, SQ: 5,139,41,73,43,71,7,137,61,29,151,17,149,19,59,31
S:6, P:2, SQ: 5,61,43,149,41,151,7,59,139,29,71,19,73,17,137,31
S:6, P:2, SQ: 5,139,43,71,41,73,7,137,61,29,149,19,151,17,59,31
S:6, P:2, SQ: 5,61,41,151,149,43,59,7,73,17,139,29,31,137,19,71
S:6, P:2, SQ: 5,61,149,43,41,151,59,7,73,17,31,137,139,29,19,71
S:6, P:2, SQ: 5,139,43,71,73,41,137,7,149,19,61,29,31,59,17,151
S:6, P:2, SQ: 5,139,73,41,43,71,137,7,149,19,31,59,61,29,17,151
S:8, P:2, SQ: 5,149,61,43,73,31,17,137,41,59,151,7,139,19,29,71
S:6, P:2, SQ: 5,73,139,41,149,31,19,59,43,137,71,7,61,17,29,151
S:6, P:2, SQ: 5,149,73,31,61,43,17,137,41,59,139,19,151,7,29,71
S:6, P:2, SQ: 5,73,149,31,139,41,19,59,43,137,61,17,71,7,29,151
S:6, P:2, SQ: 61,5,151,41,43,149,7,59,17,73,29,139,137,31,71,19
S:6, P:2, SQ: 61,5,43,149,151,41,7,59,17,73,137,31,29,139,71,19
S:6, P:2, SQ: 139,5,71,43,41,73,7,137,19,149,29,61,59,31,151,17
S:6, P:2, SQ: 139,5,41,73,71,43,7,137,19,149,59,31,29,61,151,17
S:8, P:2, SQ: 61,5,151,41,149,43,59,7,29,139,17,73,19,71,31,137
S:8, P:2, SQ: 139,5,73,41,71,43,137,7,29,61,17,151,19,149,31,59
S:6, P:2, SQ: 61,5,149,43,151,41,59,7,29,139,19,71,17,73,31,137
S:6, P:2, SQ: 139,5,71,43,73,41,137,7,29,61,19,149,17,151,31,59
S:8, P:2, SQ: 149,5,43,61,31,73,137,17,59,41,7,151,19,139,71,29
S:6, P:2, SQ: 73,5,41,139,31,149,59,19,137,43,7,71,17,61,151,29
S:6, P:2, SQ: 149,5,31,73,43,61,137,17,59,41,19,139,7,151,71,29
S:6, P:2, SQ: 73,5,31,149,41,139,59,19,137,43,17,61,7,71,151,29
S:8, P:2, SQ: 41,73,5,139,7,137,43,71,151,17,61,29,59,31,149,19
S:6, P:2, SQ: 43,149,5,61,7,59,41,151,71,19,139,29,137,31,73,17
S:6, P:2, SQ: 43,71,5,139,7,137,41,73,149,19,61,29,59,31,151,17
S:6, P:2, SQ: 149,43,5,61,59,7,41,151,31,137,73,17,19,71,139,29
S:6, P:2, SQ: 43,71,5,139,137,7,73,41,61,29,149,19,17,151,31,59
S:6, P:2, SQ: 73,41,5,139,137,7,43,71,31,59,149,19,17,151,61,29
S:8, P:2, SQ: 61,43,5,149,17,137,73,31,151,7,41,59,29,71,139,19
S:6, P:2, SQ: 139,41,5,73,19,59,149,31,71,7,43,137,29,151,61,17
S:6, P:2, SQ: 73,31,5,149,137,17,43,61,41,59,139,19,7,151,71,29
S:8, P:2, SQ: 149,31,5,73,59,19,41,139,43,137,61,17,7,71,151,29
S:6, P:2, SQ: 43,149,61,5,7,59,151,41,137,31,17,73,71,19,29,139
S:6, P:2, SQ: 71,43,139,5,7,137,41,73,29,61,19,149,151,17,59,31
S:6, P:2, SQ: 41,73,139,5,7,137,71,43,59,31,19,149,151,17,29,61
S:8, P:2, SQ: 73,41,139,5,137,7,71,43,17,151,29,61,31,59,19,149
S:6, P:2, SQ: 149,43,61,5,59,7,151,41,19,71,29,139,31,137,17,73
S:6, P:2, SQ: 71,43,139,5,137,7,73,41,19,149,29,61,31,59,17,151
S:8, P:2, SQ: 43,61,149,5,137,17,31,73,7,151,59,41,71,29,19,139
S:6, P:2, SQ: 41,139,73,5,59,19,31,149,7,71,137,43,151,29,17,61
S:6, P:2, SQ: 31,73,149,5,17,137,61,43,59,41,19,139,151,7,29,71
S:8, P:2, SQ: 31,149,73,5,19,59,139,41,137,43,17,61,71,7,29,151
S:8, P:2, SQ: 43,149,7,59,5,61,41,151,71,19,137,31,139,29,73,17
S:6, P:2, SQ: 149,43,59,7,5,61,41,151,31,137,19,71,73,17,139,29
S:6, P:2, SQ: 43,149,7,59,61,5,151,41,137,31,71,19,17,73,29,139
S:8, P:2, SQ: 149,43,59,7,61,5,151,41,19,71,31,137,29,139,17,73

On Nov 12, 2018, Emmanuel wrote:

Here is a solution with magic constant 258, minimal:
31   151  71
73   149  29   7
41  19  61   137
139  59  17  43

In bold type the smaller of the two primes for each twin used.


On Nov 16, 2018 Adam wrote:

Once I got the coding right, it was pretty easy to find examples, e.g.,

                   [5101, 2089, 4549, 821]

                   [1997, 3371, 2551, 4639]

                   [823, 4549, 2087, 5099]

                   [4637, 2549, 3373, 1999]

Once one exists, a minimal one has to exist.  To be announced, I havenít pursued minimal (magic sum) yet.  I was muddling through some different approaches that werenít really working first.  Once I latched onto the current idea I am using, Maple printed out tons of them, so it looks like they are common.

My current method is to take a 4x4 magic square using the numbers 1-16, then label the 1 as p and the 3 as p+2, 5 as q and 7 as q+2, etc., to create a model of how the twin primes would be distributed in the 4x4 square.  Then I row reduced the equations required for it to be magic, had five free variables, assigned them random twin primes (p the smaller twin prime, p+2 the larger twin prime, of course), and tested whether the non-free variables were also twin primes.  (The model means there are non-trivial solutions with non-primes, then you just look for examples when they are primes.)


After the results sent by Simon, Emmanuel and Adam I proposed to them to seek for a solution using rigorous consecutive twin-primes. This mean that in between the first and the last twin primes must not be any single-prime.

But we faced a not small problem. The sets of 8 rigorous consecutive twin-primes are not easy to get...! According to our puzzle 122, the smallest set of these start at 1107819732821 (13 digits) as was computed by Phil Carmody in the year 2001.

Using this and all the other sets of 8  rigorous consecutive twin-primes reported by Phil and also by Denis DeVries and Gabor Levai (16 sets in total)  Emmanuel Vantieghem reported that no magic solution emerged from them.

Then I had a very impertinent idea: to invite to Denis and Gabor to produce more sets of 8  rigorous consecutive twin-primes.

Gabor Levai accepted the idea and sent... 1454 sets of these!

Emmanuel found on Dec 1, 2018 that the set 1191 of these, produced the magic square sought. Here is it:

27714215764134589 27714215764134899 27714215764134959 27714215764134883
27714215764134881 27714215764134587 27714215764134901
27714215764134919 27714215764134943 27714215764134629
27714215764134631 27714215764134841 27714215764134917

There are 144 magic squares that use these primes. All the used primes are composed by 17 decimal digits.

No doubt that this magic square must be credited to both Emmanuel Vantieghem and Gabor Levai. Congratulations!!!

As far as I know this is the first and the smallest magic square of this type. Is it true? (here is where we miss so much Mr. Harvey Heinz...)


Records   |  Conjectures  |  Problems  |  Puzzles