# Prime Numbers Magic Squares

### A Large order-3

This magic square consists of 9 consecutive, 93-digit prime numbers.

### Minimum consecutive primes -3

This order-3 uses consecutive primes not in arithmetic progression.

### Minimum consecutive primes -4

This order-4 has a magic sum of 258

### Minimum consecutive primes -5

This order-5 has a magic sum of 1703. But now one with S = 313

### Minimum consecutive primes -6

An order-6 pandiagonal magic square with a surprisingly small sum.

### A Small order-3

This is the smallest possible with primes in arithmetic progression.

### Primes in arithmetic progression

An order-4 pandiagonal magic square using 14 or 15 digit primes.

### Orders 3 & 8 use consecutive primes

73 consecutive primes from 3 to 373 together form 2 magic squares.

### Orders 4, 5, 6 use consecutive primes

Prime # 37 to 103, 107 to 239 and 241 to 457 make 3 magic squares.

### A Bordered prime magic square

Orders 8, 6 and 4 using distinct 4-digit primes.

### Order-3 with smallest sum

These primes are neither consecutive or in arithmetical progression.

### Two palprime magic squares

All numbers in these order-3's are 11-digit palindromic primes.

### Order-13 constant difference

Nested squares of orders 13, 11, 9, 7, 5, 3, 1.

### Order-7 two way prime pandiagonal

Even when the unit digit of each number is removed.

### Two minimum difference squares

Order-5 add and multiply squares have minimum differences.

### Prime number - Smith number

Two order-3 magic squares, sums are 822 and 411.

### Anti-magic squares have prime sums

Two order-3 squares with minimal solutions.

### Orthomagic squares of squares

Squares of primes form a square with rows and columns magic.

### Primes and composites

The prime numbers form a capitol T in this order-5 magic square.

### Order-5 ...... with NO primes

25 consecutive composite numbers make up this super-magic square.

### Order-11 Prime-magical square

This array contains 24 different reversible 11-digit primes.

### Previously posted prime squares

Links to other prime magic squares previously posted on this site.

A Large order-3

The following 93 digit number is the first of ten consecutive primes in arithmetic progression. Each one is 210 larger then the previous one.

100 99697 24697 14247 63778 66555 87969 84032 95093 24689 19004 18036 03417 75890 43417 03348 88215 90672 29719.

 p + 1680 p + 210 p + 1260 p + 630 p + 1050 p + 1470 p + 840 p + 1890 p + 420
This series was discovered in March, 1998 by Manfred Toplic of Austria.

An order-3 prime number magic square may be constructed using the first 9 or the last nine of these primes.
This magic square uses the last nine. To save space, p is used to represent this large number in each cell. The magic constant then is 3p + 3150.

A smaller order-3 consecutive primes magic square could be constructed with the nine prime series starting with 99 67943 20667 01086 48449 06536 95853 56163 89823 64080 99161 83957 74048 58552 90714 75461 11479 96776 94651.
This series also has a difference of 210 between successive primes.

Minimum consecutive primes -3

 1480028201 1480028129 1480028183 1480028153 1480028171 1480028189 1480028159 1480028213 1480028141
These are the only two 3 x 3 magic squares composed of consecutive primes under 231. In each case the series consists of 3 triplets with a starting difference of 6 and an internal difference of 12.

Both were found by Harry Nelson who found 18 other magic squares of this type, the highest sequence starting with 9 55154 49037. All are greater then 231 which is 21474 83648.

H. L. Nelson, Journal of Recreational Mathematics, 1988, vol. 20:3, p.214

 1850590129 1850590057 1850590111 1850590081 1850590099 1850590117 1850590087 1850590141 1850590069
Type 1
 P8 P1 P6 P3 P5 P7 P4 P9 P2

Theoretically, there are two different types of arrays possible. Both of the above magic squares are type 1. There are no type 2 consecutive prime magic squares under 231, and it is not known if any even exist.
Harry J. Smith confirms that Aale de Winkel has discovered a Type 2 magic square!

Type 1 is the only magic square possible using consecutive (prime & composite) numbers.

In each case, in these 2 squares, the numbers in the cells indicate the magnitude (order) of the number in the series of 9 numbers.

See my Type 2 Order-3 page.

From a letter by Harry J. Smith of Saratoga, CA, to Dr. Michael W. Ecker dated Dec. 8/90. Farrago IX disk 4

Type 2
 P8 P1 P7 P4 P5 P6 P3 P9 P2

Minimum consecutive primes -4

 37 83 97 41 53 61 71 73 89 67 59 43 79 47 31 101
The primes 31 to 101 form a magic square with a magic sum of 258.
Author Allan W. Johnson, Jr. shows another order-4 using primes 37 to 103 and magic sum 276.
These primes are not in arithmetic progression.

This is in answer to problem 962 originally posed by Frank Rubin.

Journal of Recreational Mathematics, vol. 14:2, 1981-82, pp.152-153

Minimum consecutive primes -5

 281 409 311 419 283 359 379 349 347 269 313 307 389 293 401 397 331 337 271 367 353 277 317 373 383
The primes 269 to 419 form a magic square with a magic sum of 1703.
Author Allan W. Johnson, Jr. shows another order-5 using smaller primes 181 to 389 but a magic sum 1704.

This also in answer to problem 962 originally posed by Frank Rubin.

Journal of Recreational Mathematics, vol. 14:2, 1981-82, pp.152-153

 59 107 71 23 53 13 37 113 61 89 43 41 83 79 67 101 19 17 103 73 97 101 29 47 31

Max Alekseyey advised me that the above is not the smallest possible order-5 prime simple magic square. Several smaller ones are shown at. [1]. This is the smallest, with S = 313.

Also shown at that site is a simple order-6 magic square with S = 484

[1] http://digilander.libero.it/ice00/magic/prime/orderConstant.html

Minimum consecutive primes -6

 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
This pandiagonal magic square consists of the thirty-six consecutive primes from 67 to 251. This is the smallest series of primes possible for forming a pandiagonal order-6 magic square. See [1] (above ) for a simple order-6 with S = 484.
There are 24 different combinations of numbers that equal the magic sum of 930. The 6 rows, 6 columns, 2 main diagonals, and 10 pan diagonal pairs.

The author also shows two order-6 pandiagonal magic squares with smaller series of primes. These both use 36 primes from the series 3 to 167.

A. W. Johnson, Jr. Journal of Recreational Mathematics, vol. 23:3, 1991, pp.190-191

A Small order-3

 1669 199 1249 619 1039 1459 829 1879 409
This order-3 magic square is the smallest possible with primes in arithmetic progression   (but not consecutive).

David Wells, Penguin Dictionary of Curious & Interesting Numbers, 1986.

H. E. Dudeney, Amusements in Mathematics, Dover Publ. 1958, p. 246

Primes in arithmetic progression

 39,064,930,015,753 98,983,213,040,353 66,719,522,180,953 89,765,015,651,953 103,592,311,734,553 52,892,226,098,353 75,937,719,569,353 62,110,423,486,753 80,546,818,263,553 57,501,324,792,553 108,201,410,428,753 48,283,127,404,153 71,328,620,875,153 85,155,916,957,753 43,674,028,709,953 94,374,114,346,153

This magic square is pandiagonal with the magic sum of 294,532,680,889,012.
As with all order-4 pandiagonal magic squares, the following all sum correctly:

• 4 rows
• 4 columns
• 8 diagonals
• 16                 2 x 2 squares (including wrap-around) This qualifies it as a most-perfect magic square.
• 16 corners of 3 x 3 squares
• 16 corners of 4 x 4 squares

It is composed of the top16 of 22 prime numbers in arithmetic progression, and a common difference of 4,609,098,694,200.

The smallest possible order-4 magic square of this type may be made from the series starting with 53,297,929 and a common difference of 9,699,690.

The longest known arithmetic progression, all of whose members are prime numbers, contains 22 terms. The first term is 11,410,337,850,553 and the common difference is 4,609,098,694,200.
It was discovered on 17 March 1993 at Griffith University, Queensland.

An arithmetic progression is a sequence of numbers where each is the same amount more than the one before. For example, 5, 11, 17, 23 and 29. All of these are prime numbers, the first term is 5 and the common difference is 6.
In this example, the primes are not consecutive, because the 7, 13 and 19 are missing.

Orders 3 & 8 use consecutive primes

 3 367 97 5 281 263 173 271 137 19 151 179 269 347 257 101 359 239 373 41 227 61 71 89 31 313 349 353 107 167 127 13 241 113 29 193 59 283 211 331 197 53 191 307 163 83 317 149 311 199 47 131 17 233 293 229 181 157 223 251 337 23 11 277
 109 7 103 67 73 79 43 139 37
This pair of magic squares are constructed using the 73 consecutive primes from 3 to 373.

73 is a prime number, as is 11, the sum of the two orders.

Gakuho Abe, Journal of Recreational Mathematics, 10:2, 1977-78, pp. 96-97

Orders 4, 5, 6 use consecutive primes

 41 71 103 61 97 79 47 53 37 67 83 89 101 59 43 73

Order 4 Uses the consecutive primes from 37 to 103

Together these three magic squares use the 77 consecutive prime numbers from 37 to 457.

A. W. Johnson, Jr., Journal of Recreational Mathematics, vol. 15:1,1982-83, pp.17-18

 107 229 181 239 109 233 131 191 137 173 149 139 223 127 227 179 199 113 211 163 197 167 157 151 193

Order 5 Uses the consecutive primes from 107 to 239

 251 389 311 449 347 353 313 359 293 373 379 383 397 271 419 263 401 349 269 317 367 421 283 443 439 307 277 337 409 331 431 457 433 257 281 241

Order 6 Uses the consecutive primes from 241 to 457

A Bordered prime magic square

 2621 2477 2039 1289 3251 1583 3533 2207 3257 1361 3491 2393 2333 2963 1709 1493 2609 1811 2837 2087 2687 1889 2939 2141 2777 2819 2753 1823 1223 3701 1931 1973 2351 2879 1049 3527 2927 1997 1871 2399 1283 2339 2861 2063 2663 1913 2411 3467 1559 3041 1259 2357 2417 1787 3389 3191 2543 2273 2711 3461 1499 3167 1217 2129
This order-8 magic square borders a pandiagonal order-6 magic square, which borders an associated order-4 magic square.
All integers are distinct 4 digit prime numbers.

A. W. Johnson, Jr., Journal of Recreational Mathematics 15:2, 1982-83, p. 84

Order-3 with smallest sum

 43 1 67 61 37 13 7 73 31
The constant of this (upper) magic square is 111.

In 1913, Dudeney listed the first solvers of prime magic squares of orders 3 to 12.
This one is by himself.
However, for orders 3 and 12 (and presumably others) the number 1 was used. By present day convention, the number 1 is no longer permitted in prime number magic squares.

The constant of this (lower) magic square is 177.

Note that the primes in these magic squares are neither consecutive nor in arithmetic progression.
This magic square consists of 3 triplets with starting differences of 42, and internal differences of 12.

H. E. Dudeney, Amusements in Mathematics, Dover Publ. 1958, p. 123

 101 5 71 29 59 89 47 113 17

Two palprime magic squares

 10797779701 14336063341 12568586521 14338283341 12567476521 10796669701 12566366521 10798889701 14337173341
 10915551901 12133533121 11527872511 12137973121 11525652511 10913331901 11523432511 10917771901 12135753121

These beautiful magic squares, consisting of 11-digit palindromic primes, are by Carlos Rivera and Jaime Ayala.
As with all order-3 magic squares, these contain 3 triplets. In the case of the first magic square, the triplets start with 10796669701, 10797779701, and 10798889701 for a common difference of 1110000. The common difference within each triplet is 1769696820.

I received the first one on May 22, 1999 by e-mail. The second magic square arrived two days later. Thanks Carlos & Jaime.

Their Prime Puzzles and Problems page is at http://www.primepuzzles.net

Order-13 constant difference

 1153 8923 1093 9127 1327 9277 1063 9133 9661 1693 991 8887 8353 9967 8161 3253 2857 6823 2143 4447 8821 8713 8317 3001 3271 907 1831 8167 4093 7561 3631 3457 7573 3907 7411 3967 7333 2707 9043 9907 7687 7237 6367 4597 4723 6577 4513 4831 6451 3637 3187 967 1723 7753 2347 4603 5527 4993 5641 6073 4951 6271 8527 3121 9151 9421 2293 6763 4663 4657 9007 1861 5443 6217 6211 4111 8581 1453 2011 2683 6871 6547 5227 1873 5437 9001 5647 4327 4003 8191 8863 9403 8761 3877 4783 5851 5431 9013 1867 5023 6091 6997 2113 1471 1531 2137 7177 6673 5923 5881 5233 4801 5347 4201 3697 8737 9343 9643 2251 7027 4423 6277 6151 4297 6361 6043 4507 3847 8623 1231 1783 2311 3541 3313 7243 7417 3301 6967 3463 6907 6781 8563 9091 9787 7603 7621 8017 4051 8731 6427 2053 2161 2557 7873 2713 1087 2521 1951 9781 1747 9547 1597 9811 1741 1213 9181 9883 1987 9721
This 13 x 13 magic square of all prime numbers contains an 11 x 11, 9 x 9 7 x 7, 5 x 5, 3 x 3 magic squares.
The magic constants of the respective squares are 70681, 59807, 48933, 27185, 16311.
The common difference between each of these constants is 10874, including the difference between the 3 x 3 square and the center number 5437.

Both this and the next magic square were composed by a hobbyist while serving time in prison.

This is a concentric (not bordered) magic square.

J. S. Madachy, Mathematics on Vacation, Thomas Nelson & Sons, 1966, pp92 – 94.

 11 3851 9257 1747 6481 881 5399 6397 827 5501 71 3779 9221 1831 3881 9281 1759 6361 911 5417 17 839 5381 101 3797 9227 1861 6421 9311 1777 6367 941 5441 29 3761 5387 131 3821 9239 1741 6451 857 1801 6379 821 5471 47 3767 9341
The magic sum for this square is 27627 for every row, column, main diagonal and broken diagonal pair.

If a new square is constructed by removing the units digit from each number (11 becomes 1, 3851 becomes 385, etc), it will have the magic sum of 2760 for every row, column diagonal and broken diagonal pair!

J. S. Madachy, Mathematics on Vacation, Thomas Nelson & Sons, 1966, pp92 – 94.

Two minimum difference squares

 41 79 17 13 61 53 3 83 67 7 59 97 5 23 29 11 31 37 89 43 47 2 71 19 73

These two squares each contain the 25 primes that are less then 100.

Add: The maximum sum of any row, column or diagonal is 213

The minimum sum is 211

The difference (which is the minimum possible) is 2

Multiply
 17 59 71 89 3 31 79 5 37 41 23 2 67 73 83 29 47 13 11 97 53 43 61 7 19
Multiply: The maximum product of any line, column or diagonal is 19,013,871

The minimum product is 18,489,527

The difference which is also the minimum possible, is 524,344

Journal of Recreational Mathematics vol.26:4, 1994, pp308,309
Solutions by Michael Reid to puzzle 2094 originally posed by Rodolfo Kurchan

Prime number - Smith number

 94 382 346 526 274 22 202 166 454

A. Smith Numbers

A Smith number has the following property.

The sum of its digits is equal to the sum of the digits of its prime factors.
Take 526 as an example. The sum of 5+2+6=13 and the sum of the digits of its prime factors (2 and 263) also equals 13.

There are an infinite amount of Smith numbers, 81 within the natural numbers 1 to 2000. 29,928 among the first 1,000,000 integers.
For every repunit number whose prime factors are known, a Smith number can be constructed.

Square B is formed by dividing each number in A by 2.

The constant of magic square A is 822 (not a Smith number),
and the constant of magic square B is 411 (not a prime).

Martin Gardner, Penrose Tiles to Trapdoor Ciphers, 1989, pp 299-301
David Well, Curious and Interesting Numbers, Penguin, 1986, p 187 (# 4,937,775)

 47 191 173 263 137 11 101 83 227

B. Prime Numbers

Anti-magic squares have prime sums

 1 2 4 7 16 3 6 25 12 8 7 27 19 29 13 17 11
A normal antimagic square is an n x n array of integers from 1 to n2, arranged so that the rows, columns and diagonals sum to different but consecutive numbers. There are no order-2 or 3 normal antimagic squares.

Here we relax the definition to use non-consecutive, non-distinct numbers and show two order-3 squares that involve prime number sums

A. Every sum has only 1 prime factor.

B. The sums are the first eight primes

The squares are by Torben Mogensen and appeared on an Internet newsgroup Aug. 14, 1997.
The antimagic definition is by J. A. Lindon and appeared in J. S. Madachy, Mathematics On Vacation, Nelson, 1966, p. 103.

 2 0 1 3 5 0 6 11 12 5 0 17 13 19 5 7 2

Orthomagic squares of squares

 112 232 712 612 412 172 432 592 192
In a new approach to searching for order-3 magic squares consisting of all perfect squares, Kevin Brown has investigated squares which have the rows and columns summing the same , but not the diagonals. He calls these orthomagic squares of squares, of OMSOS for short.

He found 91 primitive OMSOS squares with common sum less then 30,000; and proved that this type of square can not have the diagonals summing correctly. Of the 91 primitive squares, 56 have a common sum that is a perfect square.

Interestingly, he found that three of the other 35 squares consist of all prime numbers. Here is the smallest one.
The common sum of the rows and columns is 5691

See his paper on OMSOS here.

Primes and composites

 19 23 11 5 7 1 10 17 24 13 22 14 3 6 20 8 16 25 12 4 15 2 9 18 21
The prime numbers in this pandiagonal magic square form a capitol T.

It was constructed by Dr. C. Planck and published in 1917.

As was common in that era, the one was included as a prime number.

By convention, the number 1 is no longer permitted in prime magic squares..

H. E. Dudeney, Amusements in Mathematics, Dover Publ. 1958, p. 246

Order-5 ...... with NO primes

 1328 1342 1351 1335 1344 1350 1334 1343 1332 1341 1347 1331 1340 1349 1333 1339 1348 1337 1346 1330 1336 1345 1329 1338 1352
This magic square consists of 25 consecutive composite numbers. It is the smallest possible such magic square of order-5.
It is a pandiagonal associative, complete and self-similar magic square with a magic sum of 6700.

Including the usual 5 rows, 5 columns and 10 diagonals, there are 328 different ways to form the sum of 6700 using 5 numbers.

Refer to "A Deluxe Magic Square" on my Pandiag.htm page for a full discussion, including definitions, of this type of magic square.

You could make an order-25 composite magic square like the above using the 625 consecutive numbers starting with  11,000,001,446,613,354.

See David Wells, Curious and Interesting Numbers, Penguin, 1986, p. 195.

Order-11 Prime-magical square

 3 7 9 7 9 9 1 3 9 7 3 7 9 1 9 1 9 1 7 9 9 9 7 1 1 9 1 9 3 9 7 9 9 1 1 1 1 3 7 9 9 7 7 1 1 1 1 7 1 7 1 9 3 3 1 1 7 3 7 1 7 9 3 7 1 1 1 7 9 9 1 3 1 1 3 3 3 3 9 1 9 1 9 1 1 3 3 7 7 7 9 9 7 1 1 3 7 9 1 7 9 3 3 3 7 7 7 7 3 9 3 3 9 3 3 9 1 3 9 1 3
This 11 x 11 square is not magic in the usual sense. The rows, columns and diagonals do not add up to the same constant.
In this case, the rows, columns and diagonals are distinct, reversible and non-palindromic primes.

So this square consists of 48 different 11-digit primes!

The puzzle was designed by Carlos Rivera and his friend Jaime Ayala and posted on their excellent Prime Puzzles and Problems page about a year ago (June, 1998).

See much more on this subject as well as lots more on prime numbers at http://www.primepuzzles.net

The above solution was sent to Carlos June 6, 1999 by Jurgen T. W. A. Baumann.

Previously posted prime squares

The following are prime magic squares that were previously posted to this site.

For convenience, I list them here with links to the corresponding pages.

Consecutive Prime Numbers Order-9 magic square ----- Material From REC
This order-9 magic square is composed of the 81 consecutive prime numbers 43 to 491.

Order-16 Prime Number Magic Square ---------------- Material From REC
This magic square contains inlays of each even order magic square from 4 to 14.

Prime Number heterosquares --------------------------- Unusual Magic Squares
Two order-3 heterosquares by Carlos Rivera. All numbers are prime.

Orders 4 & 5 Perfect Prime Squares ------------------- Prime Number Patterns
All rows, columns and the two main diagonals are distinct prime numbers when read in either direction.

Order-6 Perfect Prime Squares ------------------------ Prime Number Patterns
Rivera and  Ayala's two order-6 squares which each contain twenty-eight 6 digit primes.

Order-3 Super-Perfect Prime Square ------------------ Prime Number Patterns
1 of the 24 possible order-3 perfect prime squares. The partial diagonal pairs are also prime numbers

Type 2 - Order-3 Minimum consecutive primes -------- Type 2 Order-3
Discusses Type 2 m.s. and shows the two smallest consecutive primes order-3 magic squares. Aug. 8/99

 This page was originally posted June 1999 It was last updated July 21, 2010 Harvey Heinz   harveyheinz@shaw.ca Copyright © 1998-2009 by Harvey D. Heinz