Problems & Puzzles: Puzzles

Puzzle 333. 'Magic squares' and primes.

Sebastião A. Silva proposes the following puzzle:

'Using single digits, fill an nxn matrix with a 'magic square' having the maximum possible number of primes, counted in horizontal, vertical an diagonal lines, in both directions'. Example: n=4, magic sum=20, primes=47.

3917
2738
6194
9371"

Note: As you can see this is a variation of the puzzle 1 of these pages. Just to be precise, for the following question of this puzzle please count only distinct primes over the rows, the columns and the two main diagonals, both directions, as said above. Under these rules, the Sebastião example has only 42 distinct primes.

Question:

Find the maximal number of primes for n=2, 3, 4 & 5 (send the list of primes ordered, by rows, by columns and by major diagonals).


Solutions came from Faride Firoozbakht and Shyam Sunder Gupa:

Faride wrote:

The maximal number of primes for n=2 is 1 and the maximal number of primes for n=3 is 11, one of the corresponding magic squares in this case is:

2 7 6
9 5 1
4 3 8

primes in rows: 2,3,5,7,43,59,67,83
primes in columns: 29,53,61

For n>3 it takes many times.

***

Shyam wrote:

2X2 magic square containing maximum distinct primes:

There can be maximum one distinct prime in any 2x2 magic square. There are 5 possible such magic squares containing identical digits as 1, 2,3,5 and 7.
the 2x2 magic square containing 1 as all four elements of the magic sqaure will have one distinct prime 11.
the 2x2 magic square containing 2,3,5 or 7  as all four elements of the magic sqaure will have one distinct prime 2,3,5 or 7 resp.in each magic square.


3X3 magic square containing maximum distinct primes:

There can be maximum 11 distinct primes in any 3x3 magic square. The 3x3 magic square (and all its images) containg maximum 11 distinct primes is:

Magic Sum = 15

2  7    6
9  5    1 
4  3    8

The 11 distinct primes are: 2,3,5,7,29,43,53,59,61,67 and 83.


4X4 magic square containing maximum distinct primes:

There can be maximum 46 distinct primes in any 4x4 magic square. The 4x4 magic square (and all its images) containing maximum 46 distinct primes are:

Magic Sum = 23

1  4    9  9
9  7    4  3   
6  3    9  5
7  9    1  6

The 46 distinct primes are 3,5,7,17,19,37,41,43,47,53,59,61,67,71,73,79,97,149,179,197,347,349,
479,491,499,593,619,653,691,739,743,769,937,941,967,971,1499,1949,
6197,6971,7349,7691,9437,9491,9743 and 9941.         
           
Another 4X4 magic square containing 46 distinct primes:

Magic Sum = 22


1  6    6  9
9  5    7  1   
9  3    7  3
3  8    2  9

The 46 distinct primes are
2,3,5,7,13,17,19,29,31,37,53,59,61,67,71,73,79,83,97,139,157,199,277,
283,337,373,379,571,653,661,677,733,739,751,829,937,991,1579,1669,1759,1993,3739,9283,9319,9661 and 9733.         
           
All other 4x4 magic squares containing 46 distinct primes are variant of above 2 magic squares only.

***

Shyam wrote, on October 30, 2005:

I have been able to find a 5x5 magic square (given below) with 85 distinct primes.

Magic Sum = 23

1          9          7          3          3         
6          1          4          9          3
7          1          5          3          7
6          3          6          7          1
3          9          1          1          9

The distinct primes are:
           
3,5,7,11,13,17,19,31,37,41,47,53,59,61,67,71,73,79,97, 
113,139,149,157,167,173,193,197,311,337,359,367,379,
547,593,719,733,739,751,761,911,937,941,953,1193,1493,
1579,1733,1973,3119,3359,3371,3517,3593,3671,3719,3911,
4561,6367,6547,6761,6763,7351,7393,9173,9311,9371,9533,
9733,11579,16547, 16763,17393,33791,36761,39119,39371, 
61493,63671,71537,73517,74561,91139,91193,91733 and 97511.

            It requires a very long time to ascertain maximum distinct
primes in 5x5 magic square.
       
Can any body beat my record of 85 distinct primes in 5x5 magic square?.

***


Records   |  Conjectures  |  Problems  |  Puzzles