Office Applications and Entertainment, Magic Squares  Index About the Author

14.0    Special Magic Squares, Prime Numbers

14.13   Consecutive Primes

Prime Number Magic Squares with Consecutive Primes can be generated with comparable routines as described in Section 14, however based on consecutive prime variable values {ai} with i = 1 ... n.

14.13.1 Magic Squares (4 x 4)

Based on the equations defining a Magic Square of the fourth order:

```a(13) =  s1 - a(14) - a(15) - a(16)
a( 9) =  s1 - a(10) - a(11) - a(12)
a( 7) =       a( 8) - a(10) + a(12) - a(13) + a(16)
a( 6) =  s1 - a( 8) - a(11) - a(12) + a(13) - a(16)
a( 5) =     - a( 8) + a(10) + a(11)
a( 4) =  s1 - a( 7) - a(10) - a(13)
a( 3) = -s1 - a( 8) + a( 9) + 2 * a(10) +         2 * a(13) + a(14)
a( 2) =       a( 8) - a( 9) - 2 * a(10) + a(15) + 2 * a(16)
a( 1) =       a( 8) + a(12) - a(13)
```

and preselected ranges of consecutive primes, routine Priem4b2 can be used to generate order 4 Prime Number Magic Squares with Consecutive Prime Numbers.

Prime Number Magic Squares with Consecutive Prime Numbers for MC = 258 (32 ea) and MC = 276 (64 ea) were already found by means of routine Priem4 and shown in Attachment 14.2.1.

Attachment 14.13.1 shows for a few higher Magic Sums the first occurring Prime Number Magic Square with Consecutive Prime Numbers.

Each square shown corresponds with numerous Prime Number Magic Squares with the same Magic Sum and variable values.

14.13.2 Magic Squares (5 x 5)

Based on the equations defining a Magic Square of the fifth order:

```a(21) =  s1 - a(22) - a(23) - a(24) - a(25)
a(16) =  s1 - a(17) - a(18) - a(19) - a(20)
a(11) =  s1 - a(12) - a(13) - a(14) - a(15)
a( 9) =       a(10) - a(13) + a(15) - a(17) + a(20) - a(21) + a(25)
a( 7) = (s1 - a( 8) - a( 9) - a(10) + a(11) - a(13) + a(16) - a(19) + a(21) - a(25))/2
a( 6) =  s1 - a( 7) - a( 8) - a( 9) - a(10)
a( 5) =  s1 - a( 9) - a(13) - a(17) - a(21)
a( 4) =  s1 - a( 9) - a(14) - a(19) - a(24)
a( 3) =  s1 - a( 8) - a(13) - a(18) - a(23)
a( 2) =  s1 - a( 7) - a(12) - a(17) - a(22)
a( 1) =  s1 - a( 2) - a( 3) - a( 4) - a( 5)
```

and preselected ranges of consecutive primes, routine Priem5b2 can be used to generate order 5 Prime Number Magic Squares with Consecutive Prime Numbers.

Attachment 14.13.2 shows for miscellaneous Magic Sums the first occurring Prime Number Magic Square with Consecutive Prime Numbers.

Each square shown corresponds with numerous Prime Number Magic Squares with the same Magic Sum and variable values.

One of the possible aspects of the smallest square (MC = 313) was previously published by Max Alekseyey (2009).

14.13.3 Pan Magic Squares (6 x 6)

Based on the equations defining a Pan Magic Square of the sixth order:

```a(31) =        s1 - a(32) - a(33) - a(34) - a(35) - a(36)
a(25) =        s1 - a(26) - a(27) - a(28) - a(29) - a(30)
a(19) =        s1 - a(20) - a(21) - a(22) - a(23) - a(24)
a(17) =  2/3 * s1 - a(18) + a(20) + a(21) - a(23) - a(24) + a(26) + a(27) - a(29) - a(30) - a(35) - a(36)
a(16) =    2 * s1 + a(18) - a(20) - 2*a(21) - 2*a(22) - a(23) - a(26) - 2*a(27) - 2*a(28) - a(29) - a(34) + a(36)
a(15) =  2/3 * s1 - a(18) - a(33) - a(36)
a(14) =             a(18) - a(20) - a(21) + a(23) + a(24) - a(26) - a(27) + a(29) + a(30) - a(32) + a(36)
a(13) = -4/3 * s1 - a(18) + a(20) + 2*a(21) + 2*a(22) + a(23) + a(26) + 2*a(27) + 2*a(28) + a(29) - a(31) - a(36)
a(12) = 11/6 * s1 - a(20) - a(21) - a(22) - a(26) - 2*a(27) - a(28) - a(32) - a(33) - a(34)
a(11) = -7/6 * s1 + a(22) + a(23) + a(24) - a(26) + a(28) + a(29) + a(30) + a(34) + a(35) + a(36)
a(10) = -7/6 * s1 + a(21) + a(22) + a(23) - a(25) + a(27) + a(28) + a(29) + a(33) + a(34) + a(35)
a(9)  = -7/6 * s1 + a(20) + a(21) + a(22) + a(26) + a(27) + a(28) - a(30) + a(32) + a(33) + a(34)
a(8)  = 11/6 * s1 - a(22) - a(23) - a(24) - a(28) - 2*a(29) - a(30) - a(34) - a(35)-a(36)
a(7)  = 11/6 * s1 - a(21) - a(22) - a(23) - a(27) - 2*a(28) - a(29) - a(33) - a(34)-a(35)
a(6)  = -5/6 * s1 - a(18) + a(20) + a(21) + a(22) - a(24) + a(26) + 2*a(27) + a(28)-a(30)+a(32)+a(33)+a(34)-a(36)
a(5)  =  1/2 * s1 + a(18) + a(19) + a(24) - a(27) - a(28) - a(29) - a(34) - a(35)
a(4)  =  1/6 * s1 - a(18) + a(20) + a(21) - a(28) - a(29) - a(30) + a(31) + a(32)
a(3)  =  1/2 * s1 + a(18) - a(20) - 2*a(21) - a(22) - a(26) - 2*a(27) - a(28) + a(30) + a(31) + a(35) + 2*a(36)
a(2)  =  1/6 * s1 - a(18) + a(21) + a(22) - a(25) - a(26) - a(30) + a(34) + a(35)
a(1)  =  1/2 * s1 + a(18) + a(23) + a(24) - a(25) - a(26) - a(27) - a(31) - a(32)
```

and preselected ranges of consecutive primes, routine Priem6b1 can be used to generate order 6 Prime Number Magic Squares with Consecutive Prime Numbers.

Although the first range of 36 Consecutive Primes with a valid Magic Sum MC6 = 930 can be determined, subject routine is not very feasible due to the high number of independent variables (16 ea).

In spite of the above following solution for MC6 = 930 was found by A. W. Johnson Jr (1981/82):

 67 193 71 251 109 239 139 233 113 181 157 107 241 97 191 89 163 149 73 167 131 229 151 179 199 103 227 101 127 173 211 137 197 79 223 83

Subject square corresponds with numerous Prime Number Pan Magic Squares with the same Magic Sum and variable values.

14.13.4 Simple Magic Squares (6 x 6)

Prime Number Simple Magic Squares of order 6 can be constructed very efficiently with the Generator Principle, as applied for the construction of Bimagic Squares.

The Generator Method, as applied for Consecutive Prime Numbers can be summarised as follows:

• Generate the Magic Series for the applicable 36 Consecutive Prime Numbers and the related Magic Constant (ref. MgcLns6);
• Construct Generators with 6 Magic Rows, based on the Magic Series obtained above (ref. CnstrGen01);
• Construct Semi Magic Squares based on the Generators obtained above, by permutating the numbers within the rows and determine the number of related Magic Squares (ref. CnstrSqrs6);
• Permutate the rows and columns within the Semi Magic Squares, in order to obtain Magic Squares (if possible).

For the Consecutive Prime Numbers used in Section 14.13.3 above (MC6 = 930), 12980 Magic Series could be generated, resulting in numerous Generators.

In order to limit the collection a little bit, 585 Generators were selected based on the application of 8 Unique Magic Series for each Generator.

The first Generator resulted already in 566 Semi Magic Squares with 671 related Simple Magic Squares.

The first occurring Semi Magic Square and the resulting Simple Magic Square - after row and column permutation(s) - are shown below:

Semi Magic Square
 67 79 233 191 181 179 71 229 101 197 193 139 73 239 103 199 149 167 227 83 173 127 163 157 241 89 223 109 131 137 251 211 97 107 113 151
Simple Magic Square
 101 197 193 139 71 229 103 199 149 167 73 239 173 127 163 157 227 83 223 109 131 137 241 89 97 107 113 151 251 211 233 191 181 179 67 79

The method described above has been applied for miscellaneous Magic Sums, for which the first occurring Simple Magic Squares are shown in Attachment 14.13.4.

Each square shown corresponds with numerous Prime Number Magic Squares with the same Magic Sum and variable values.

14.13.5 Simple Magic Squares (7 x 7)

Prime Number Simple Magic Squares of order 7 can be constructed with the Generator Principle, as discussed in Section 14.13.4 above.

A possible Semi Magic Square and resulting Simple Magic Square are shown below, for the smallest consecutive prime numbers {7 ... 239} for which an Order 7 Simple Magic Square exists (MC7 = 797):

Semi Magic Square
 7 17 193 167 163 137 113 11 19 97 191 179 149 151 13 23 211 181 109 157 103 67 197 199 127 53 71 83 227 223 31 43 61 73 139 233 89 29 41 173 131 101 239 229 37 47 59 79 107
Simple Magic Square
 13 23 109 103 181 211 157 227 223 61 139 43 31 73 7 17 163 113 167 193 137 239 229 59 107 47 37 79 11 19 179 151 191 97 149 233 89 173 101 41 29 131 67 197 53 83 127 199 71

The Generator Method has been applied for miscellaneous Magic Sums, for which the first occurring Simple Magic Squares are shown in Attachment 14.13.5.

Each square shown corresponds with numerous Prime Number Magic Squares with the same Magic Sum and variable values.

14.13.6 Simple Magic Squares (8 x 8)

Also Prime Number Simple Magic Squares of order 8 can be constructed with the Generator Principle, as applied in previous sections.

A possible Semi Magic Square and resulting Simple Magic Square are shown below, for the smallest consecutive prime numbers {79 ... 439} for which an Order 8 Simple Magic Square exists (MC8 = 2016):

Semi Magic Square
 439 433 137 157 179 191 229 251 431 421 131 151 277 181 197 227 419 389 127 281 163 193 211 233 379 353 113 149 337 199 223 263 97 109 409 383 173 349 257 239 89 103 401 139 373 307 311 293 83 101 331 359 347 283 271 241 79 107 367 397 167 313 317 269
Simple Magic Square
 229 439 433 137 191 179 157 251 197 431 421 131 181 277 151 227 311 89 103 401 307 373 139 293 271 83 101 331 283 347 359 241 223 379 353 113 199 337 149 263 257 97 109 409 349 173 383 239 211 419 389 127 193 163 281 233 317 79 107 367 313 167 397 269

The Generator Method has been applied for miscellaneous Magic Sums, for which the first occurring Simple Magic Squares are shown in Attachment 14.13.6.

Each square shown corresponds with numerous Prime Number Magic Squares with the same Magic Sum and variable values.

14.13.7 Summary

The obtained results regarding the miscellaneous types of Prime Number Magic Squares as deducted and discussed in previous sections are summarized in following table:

 Order Main Characteristics Subroutine Results 4 Consecutive Primes, Simple Magic 5 Consecutive Primes, Simple Magic 6 Consecutive Primes, Simple Magic Consecutive Primes, Pan    Magic - 7 Consecutive Primes, Simple Magic - 8 Consecutive Primes, Simple Magic -
 Following sections will explain the concept of Prime Number Magic Squares composed of Twin Primes and illustrate how subject squares can be generated with comparable routines as described in previous sections.