cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 11 results. Next

A073520 Smallest magic constant for any n X n magic square made from consecutive primes, or 0 if no such magic square exists.

Original entry on oeis.org

2, 0, 4440084513, 258, 313, 484, 797, 2016, 2211, 2862, 4507, 6188, 6325, 9660, 12669, 13016, 16857, 19530, 23069, 28184, 38761, 46302, 42515, 49846, 59087, 70260, 73385, 78960, 97267, 98316, 111023, 124454, 134641, 152952, 163043, 180596, 195975, 218432, 237623, 293182, 276243, 298868
Offset: 1

Views

Author

N. J. A. Sloane, Aug 29 2002

Keywords

Examples

			A square of order 15 found by _Natalia Makarova_, communicated by Stefano Tognon, Sep 23 2009:
[  131  167  229  461  541  617  733  911  967 1091 1259 1279 1319 1471 1493
   547  907 1583 1613  149 1423  193 1601  941  137  233  389 1039 1283  631
  1019  181  751  163 1453 1301 1297 1277  271 1619 1327  691  277  281  761
  1307  719  359  919 1063  653 1237  269 1433  863 1439  313  191 1021  883
   503 1367  433 1013  829 1153  317  347 1109  491 1249  677 1451 1489  241
   421  311 1487  439 1049 1409 1123  463  409  983  449 1031 1163  373 1559
  1399 1193  419 1531  971  647  977 1051  709  479 1229  379  353 1093  239
   599  953 1213  587  499  727 1321  787  307 1151  157 1571 1033  773  991
   211 1291 1499  577 1087  349  947  467  739  613 1171 1609  173  839 1097
   563  139 1373 1459 1289  443  619 1201 1427  809  881 1303  331  263  569
   607 1607 1511  673 1181 1481 1217  523  661  857  223  743  197  431  757
   853  643  701  179 1483  571  769  859 1447  659  929  997 1223 1129  227
  1549  887  257  557  367 1061  601  337 1361  937 1231  811 1543  293  877
  1579 1187  397 1069  509  683  797 1567  401  383  641  283  823  827 1523
  1381 1117  457 1429  199  151  521 1009  487 1597  251  593 1553 1103 821]
		

References

  • Allan W. Johnson, Jr., Journal of Recreational Mathematics, vol. 14:2, 1981-82, pp. 152-153.
  • Allan W. Johnson, Jr., Journal of Recreational Mathematics, vol. 23:3, 1991, pp. 190-191.
  • H. L. Nelson, Journal of Recreational Mathematics, 1988, vol. 20:3, p. 214.
  • Clifford A. Pickover, The Zen of Magic Squares, Circles and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002.

Crossrefs

Cf. A104157: smallest element in an n X n magic squares of consecutive primes.
Cf. A073519 and A320873 (3 X 3 magic square of consecutive primes), A073521 (consecutive primes of a 4 X 4 magic square), A245721 and A320874 (4 X 4 pandigital magic square of consecutive primes), A073522 (consecutive primes of a 5 X 5 magic square, non-minimal and non-pandiagonal), A073523 and A320876 (6 X 6 pandigital magic square of consecutive primes).
Cf. A256234: magic sums of 4 X 4 pandiagonal magic squares of consecutive primes.

Programs

  • PARI
    A073520(n,p=A104157[n])=sum(i=2,n^2,p=nextprime(p+1),p)/n \\ Assumes a pre-computed array A104157, but can be used to find a(n) and A104157(n) by calculating this for supplied primes p until the result satisfies the condition of the conjecture in FORMULA. - M. F. Hasler, Oct 29 2018

Formula

Conjecture: for n >= 5, a(n) equals the smallest integer of the form (A000040(s+1) + ... + A000040(s+n^2))/n = (A007504(s+n^2) - A007504(s))/n of the same parity as n.
a(2) = 0, otherwise a(n) = (1/n) * Sum_{m=k..n^2+k-1} A000040(m), where k = A049084(A104157(n)). - Arkadiusz Wesolowski, Nov 06 2015
In the above, A049084 could be replaced by A000720 = primepi. - M. F. Hasler, Oct 29 2018

Extensions

a(5)-a(6) corrected and a(7)-a(14) added, from the work of Stefano Tognon and Natalia Makarova, by Max Alekseyev, Sep 23 2009
a(15) from Natalia Makarova, a(16) and further terms from Stefano Tognon
Edited by Max Alekseyev, Oct 13 2009
Edited and more terms (using A104157) from M. F. Hasler, Oct 29 2018

A073519 The set of nine consecutive primes forming a 3 X 3 magic square with the smallest magic constant (4440084513).

Original entry on oeis.org

1480028129, 1480028141, 1480028153, 1480028159, 1480028171, 1480028183, 1480028189, 1480028201, 1480028213
Offset: 1

Views

Author

N. J. A. Sloane, Aug 29 2002

Keywords

Comments

The square is given (with the terms in correct order) in A320873. The (increasingly ordered) set of primes does not contain more information than the magic constant (= sum) S, since they have to be consecutive and sum up to 3*S. It is easy to construct the unique set of (consecutive) primes with this property, cf. PROGRAM. - M. F. Hasler, Oct 28 2018

Examples

			The magic square is
[ 1480028201 1480028129 1480028183 ]
[ 1480028153 1480028171 1480028189 ]
[ 1480028159 1480028213 1480028141 ]
		

References

  • H. L. Nelson, Journal of Recreational Mathematics, 1988, vol. 20:3, p. 214.
  • Clifford A. Pickover, The Zen of Magic Squares, Circles and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002.

Crossrefs

Programs

  • PARI
    A073519=MagicPrimes(4440084513,3) \\ where: (also used in A073521, ...)
    MagicPrimes(S, n, P=[nextprime(S\n)])={S=n*S-P[1]; for(i=1, -1+n*=n, S-=if(S>(n-i)*P[1], P=concat(P, nextprime(P[#P]+1)); P[#P], P=concat(precprime(P[1]-1), P); P[1])); if(S, -P, P)} \\ The vector of n^2 primes whose sum is n*S, or a negative vector with an approximate solution if no exact solution exists. - M. F. Hasler, Oct 22 2018

A073523 The set of 36 consecutive primes that form a 6 X 6 pandiagonal magic square with the smallest magic constant (930).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Aug 29 2002

Keywords

Comments

There exist non-pandiagonal 6 X 6 magic squares composed of consecutive primes with smaller magic constant, the smallest being A073520(6) = 484.
Pandiagonal means that not only the 2 main diagonals, but all other 10 diagonals also have the same sum, Sum_{i=1..6} A[i,M6(k +/- i)] = 930 for k = 1, ..., 6 and M6(x) = y in {1, ..., 6} such that y == x (mod 6). - M. F. Hasler, Oct 20 2018
See A320876 for the primes in the order in which they appear in the matrix. - M. F. Hasler, Oct 22 2018

Examples

			The magic square is
  [  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 ]
		

References

  • Allan W. Johnson, Jr., Journal of Recreational Mathematics, vol. 23:3, 1991, pp. 190-191.
  • Clifford A. Pickover, The Zen of Magic Squares, Circles and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002.

Crossrefs

Cf. A073519 and A320873 (3 X 3 magic square of consecutive primes), A073521 (consecutive primes of a 4 X 4 magic square), A245721 and A320874 (consecutive primes of a 4 X 4 pandigital magic square), A073522 (consecutive primes of a 5 X 5 magic square, not minimal and not pan-diagonal).
Cf. A256234: magic sums of 4 X 4 pandiagonal magic squares of consecutive primes, A073520: magic sums for n X n squares of consecutive primes.

Programs

Extensions

Edited by Max Alekseyev, Sep 24 2009
Edited by M. F. Hasler, Oct 29 2018

A073522 A set of 25 consecutive primes that form a 5 X 5 magic square with the (non-minimal) magic constant 1703.

Original entry on oeis.org

269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419
Offset: 1

Views

Author

N. J. A. Sloane, Aug 29 2002

Keywords

Comments

The magic constant here is not the smallest possible for a 5 X 5 magic square composed of consecutive primes, this would be A073520(5) = 313 corresponding to primes (13, 17, ..., 113). [Edited by M. F. Hasler, Oct 29 2018]

Examples

			The magic square is
[ 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 ]
		

References

  • Allan W. Johnson, Jr., Journal of Recreational Mathematics, vol. 14:2, 1981-82, pp. 152-153.
  • Clifford A. Pickover, The Zen of Magic Squares, Circles and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002.

Crossrefs

Cf. A073519 and A320873 (minimal 3 X 3 magic square of consecutive primes), A073520 (minimal magic sum for n X n square of consecutive primes), A073521 (consecutive primes of a 4 X 4 magic square), A073523 (consecutive primes of a pandiagonal 6 X 6 magic square).

Programs

Extensions

Edited by Max Alekseyev, Sep 24 2009

A104157 Smallest of n^2 consecutive primes that form an n X n magic square with the least magic constant, or 0 if no such magic square exists.

Original entry on oeis.org

2, 0, 1480028129, 31, 13, 7, 7, 79, 37, 23, 67, 89, 13, 89, 131, 31, 71, 47, 43, 73, 277, 353, 41, 67, 127, 223, 79, 13, 193, 5, 23, 43, 5, 67, 3, 19, 5, 59, 59, 653, 19, 19, 97, 409, 5, 383, 29, 137, 379, 349, 653, 1187, 47, 41, 37, 17, 619, 89, 283, 283, 43, 479, 191
Offset: 1

Views

Author

Robert G. Wilson v, Mar 09 2005

Keywords

Comments

The magic constants (= sums) are given in A073520. For a given sum, the corresponding list of primes (and thus also the smallest one) is easily calculated, cf. PARI code. - M. F. Hasler, Oct 29 2018

References

  • H. L. Nelson, Journal of Recreational Mathematics, 1988, vol. 20:3, p. 214.
  • Clifford A. Pickover, The Zen of Magic Squares, Circles and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002.

Crossrefs

Cf. A073519 or A320873 (the square for 3 X 3), A073520 (magic sums for 4 X 4 squares of consecutive primes), A073521 (consecutive primes of a 4 X 4 magic square), A073522 (consecutive primes of a (non minimal!) 5 X 5 magic square), A073523 (consecutive primes of a pandiagonal 6 X 6 magic square).

Programs

  • PARI
    A104157(n)=MagicPrimes(A073520[n],n)[1] \\ See A073519 for MagicPrimes(). This code uses a precomputed array A073520, but in practice one would rather compute that sequence as function of this one. - M. F. Hasler, Oct 29 2018

Formula

Conjecture: for n > 4, a(n) = prime(s) where s > 1 is the smallest integer such that (Sum_{i=s..s+n^2-1} prime(i))/n is an integer of the same parity as n. - Max Alekseyev, Jan 29 2010
a(n) = prime(i) such that Sum_{k=0..n^2-1} prime(i+k) = n*A073520(n). - M. F. Hasler, Oct 29 2018

Extensions

a(5)-a(6) corrected, a(7)-a(20) added by Max Alekseyev, Sep 24 2009
Definition edited by N. J. A. Sloane, Oct 03 2009
More terms from Max Alekseyev, Jan 29 2010

A268790 Magic sums of 3 X 3 magic squares composed of primes.

Original entry on oeis.org

177, 213, 219, 267, 309, 327, 381, 393, 411, 417, 447, 453, 471, 501, 519, 537, 573, 579, 633, 681, 717, 723, 753, 771, 789, 807, 813, 843, 849, 879, 921, 933, 1011, 1041, 1047, 1059, 1077, 1101, 1119, 1137, 1149, 1167, 1191, 1203, 1227, 1257, 1263, 1293
Offset: 1

Views

Author

Arkadiusz Wesolowski, Feb 13 2016

Keywords

Comments

From Robert Israel, Feb 16 2016: (Start)
All terms are 3 times odd primes.
3*p is a term if and only if p is a prime not in A073350.
Conjecture: 3*p is a term for every prime > 859.
I verified this for all primes < 100000.
The Green-Tao theorem implies the sequence is infinite: given one magic square with entries a(i,j), there are infinitely many pairs of positive integers x,y such that b(i,j) = x + y*a(i,j) are all prime. Then b(i,j) form another magic square. (End)
Every number of the form 3*(A227284(n) + 840) is in this sequence. - Arkadiusz Wesolowski, Feb 22 2016
The terms equal three times the central elements (and equivalently, one third of the sum of all elements) of the 3 X 3 magic squares made of primes, which are listed in A320872. - M. F. Hasler, Oct 28 2018

Examples

			Examples of 3 X 3 magic squares composed of primes.
.
+---+---+---+
| 17| 89| 71|
+---+---+---+
|113| 59| 5 |
+---+---+---+
| 47| 29|101|
+---+---+---+
The magic constant is 177 = a(1).
.
+---+---+---+
| 41| 89| 83|
+---+---+---+
|113| 71| 29|
+---+---+---+
| 59| 53|101|
+---+---+---+
The magic constant is 213 = a(2).
		

Crossrefs

Programs

  • Maple
    N:= 10000: # to get all terms <= N P:= select(isprime,{seq(p,p=3..2*N/3,2)}):
    count:= 0:
    for ic from 1 while P[ic] <= N/3 do
       c:= P[ic];
       V:= map(`-`,P[ic+1..-1],c) intersect map(t -> c-t, P[1..ic-1]);
       nv:= nops(V);
       VV:= {seq(seq(V[j]-V[i],j=i+1..nv),i=1..nv-1)} intersect V;
       nvv:= nops(VV);
       found:= false;
       for ia from 1 to nvv while not found do
         a:= VV[ia];
         for ib from ia+1 to nvv while VV[ib] < c - a do
           b:= VV[ib];
           if b <> 2*a and {c-a-b,c-a+b,c-b+a,c+a+b} subset P then
              found:= true;
              count:= count+1;
              A[count]:= 3*c;
              break
           fi
         od
       od:
    od:
    seq(A[i],i=1..count); # Robert Israel, Feb 16 2016
  • PARI
    c=3;A268790_vec=3*vector(50,i,c=A320872_row(1,0,c+1)[2,2]) \\ Illustrates formula & comment. - M. F. Hasler, Oct 28 2018
    
  • PARI
    is_A268790(c)={denominator(c/=3)==1&& isprime(c)&& forstep(a=2,c\2-1,2, isprime(c-a)&& isprime(c+a)&& forstep(b=2,c-2*a-2,2, isprime(c-2*a-b)&& isprime(c-a-b)&& isprime(c-b)&& isprime(c+b)&& isprime(c+a+b)&& isprime(c+2*a+b)&& return(1)))} \\ M. F. Hasler, Oct 28 2018

Formula

If conjecture is true, a(n) = 3*prime(n+40) for n >= 110. - Robert Israel, Feb 16 2016
A268790 = 3*{column 5 of A320872} as a set, i.e., with duplicates removed. - M. F. Hasler, Oct 28 2018

A320872 For all possible 3 X 3 magic squares made of primes, in order of increasing magic sum, list the lexicographically smallest representative of each equivalence class (modulo symmetries of the square), as a row of the 9 elements (3 rows of 3 elements each).

Original entry on oeis.org

17, 89, 71, 113, 59, 5, 47, 29, 101, 41, 89, 83, 113, 71, 29, 59, 53, 101, 37, 79, 103, 139, 73, 7, 43, 67, 109, 29, 131, 107, 167, 89, 11, 71, 47, 149, 43, 127, 139, 199, 103, 7, 67, 79, 163, 37, 151, 139, 211, 109, 7, 79, 67, 181, 43, 181, 157, 241, 127, 13, 97, 73, 211
Offset: 1

Views

Author

M. F. Hasler, Oct 25 2018

Keywords

Comments

Magic squares of size 3 X 3 must be of the form
[ c-a-b c+b c+a ]
[ c+2a+b c c-2a-b ]
[ c-a c-b c+a+b ]
or any of the eight variants obtained by reflection(s) on any of the 4 symmetry axes of the square (horizontal, vertical and diagonals), which also produce the rotations by 90°, 180° and 270°. Of these eight variants the displayed one with a > b > 0 is the smallest one, with b > a > 0 the next larger one. (Strict inequalities since we require all elements to be distinct.) In this sequence we also restrict all entries to be primes, which may exclude one of the two possibilities (a > b or b > a).
The central elements, a(5 + 9k), k >= 0, or column 5 = T(n,5) if the sequence is seen as a table with rows of length 9, are (59, 71, 73, 89, 103, 109, 127, 127, 131, 137, 139, 149, 151, 157, 167, 167, 173, 179, 191, 191, ...). (Sequence not in OEIS.) If the primes are multiplied by three and duplicates are removed, one gets A268790 = list of magic sums of 3 X 3 magic squares of primes.

Examples

			The first four rows,
  17, 89, 71, 113, 59, 5, 47, 29, 101,
  41, 89, 83, 113, 71, 29, 59, 53, 101,
  37, 79, 103, 139, 73, 7, 43, 67, 109,
  29, 131, 107, 167, 89, 11, 71, 47, 149, (...)
correspond to the following magic squares:
   [ 17, 89, 71 ]    [ 41, 89,  83]    [ 37, 79, 103]    [ 29, 131, 107]
   [113, 59,  5 ]    [113, 71,  29]    [139, 73,  7 ]    [167,  89,  11]
   [ 47, 29, 101]    [ 59, 53, 101]    [ 43, 67, 109]    [ 71,  47, 149]
The seventh and eighth row are two inequivalent magic squares for the same magic sum 3*127:
   [ 43, 181, 157]         [ 73, 151, 157]
   [241, 127,  13]   and   [211, 127,  43] .  (The pair (13, 241) is replaced
   [ 97,  73, 211]         [ 97, 103, 181]     by (103, 151).)
		

Crossrefs

Cf. A320871: list of all inequivalent 3 X 3 magic squares (not only primes).
Cf. A320873: the first row consisting of a set of consecutive primes.
Cf. A268790: list of magic sums (= 3*(central term) = (row sum)/3), without duplicates.

Programs

  • PARI
    A320872_row(N=10,show=1,c=3)={forprime(c=c,, forstep(d=c-3,2,-2, isprime(c-d)&& isprime(c+d)&& forstep(b=max(2*d+3-c,2),d-2,2, d!=2*b&& isprime(c-2*d+b)&& isprime(c-b)&& isprime(c-d+b)&& isprime(c+d-b)&& isprime(c+2*d-b)&& isprime(c+b)&& (S=[c-d,c+b,c+d-b;c+2*d-b,c,c-2*d+b;c-d+b,c-b,c+d])&& !(show&&print(S))&& !N--&& return(S))))} \\ The 3rd (optional) argument allows computation of the list starting with the first row having a central element >= c or equivalently a magic sum >= 3c. The multiple isprime() can all be avoided using simply vecmin(apply(isprime,S=[...])), but this is significantly slower, which matters if used as proposed in A268790.

A245721 The set of 16 consecutive primes forming a 4 X 4 pandiagonal magic square with the smallest magic constant, 682775764735680 = A256234(1).

Original entry on oeis.org

170693941183817, 170693941183847, 170693941183859, 170693941183861, 170693941183889, 170693941183891, 170693941183903, 170693941183907, 170693941183933, 170693941183937, 170693941183949, 170693941183951, 170693941183979, 170693941183981, 170693941183993, 170693941184023
Offset: 1

Views

Author

Max Alekseyev, Jul 30 2014

Keywords

Comments

Also, the set of 16 smallest consecutive primes forming a 4x4 Stanley antimagic square.
The set of primes is uniquely and straightforwardly determined by the magic sum, here A256234(1), cf. PROGRAM. See A320874 for the ordered list, i.e., the lexicographic smallest magic square made of these primes. - M. F. Hasler, Oct 23 2018

Examples

			A pandiagonal magic square formed by these primes:
  170693941183817 170693941183933 170693941183949 170693941183981
  170693941183979 170693941183951 170693941183847 170693941183903
  170693941183891 170693941183859 170693941184023 170693941183907
  170693941183993 170693941183937 170693941183861 170693941183889
A Stanley antimagic square formed by these primes:
  170693941183817 170693941183859 170693941183907 170693941183949
  170693941183847 170693941183889 170693941183937 170693941183979
  170693941183861 170693941183903 170693941183951 170693941183993
  170693941183891 170693941183933 170693941183981 170693941184023
		

Crossrefs

Cf. A320874 (the square made of the set of primes given here).
Cf. A073519 or A320873, A073521, A073522 (3 X 3, 4 X 4 and 5 X 5 consecutive primes), A073523 and A320876 (6 X 6 consecutive primes, pandiagonal magic square).
Cf. A210710: Minimal index of a Stanley antimagic square of order n consisting of distinct primes.
Cf. A073520: Smallest magic sum of a magic square made of n^2 consecutive primes.
Cf. A104157: Smallest of n X n consecutive primes forming a magic square.
Cf. A256234: Magic sums of 4 X 4 pandiagonal magic squares of consecutive primes.

Programs

A217568 Rows of the 8 magic squares of order 3 and magic sum 15, lexicographically sorted.

Original entry on oeis.org

2, 7, 6, 9, 5, 1, 4, 3, 8, 2, 9, 4, 7, 5, 3, 6, 1, 8, 4, 3, 8, 9, 5, 1, 2, 7, 6, 4, 9, 2, 3, 5, 7, 8, 1, 6, 6, 1, 8, 7, 5, 3, 2, 9, 4, 6, 7, 2, 1, 5, 9, 8, 3, 4, 8, 1, 6, 3, 5, 7, 4, 9, 2, 8, 3, 4, 1, 5, 9, 6, 7, 2
Offset: 1

Views

Author

Jean-François Alcover, Oct 08 2012

Keywords

Comments

See A320871, A320872 and A320873 for the list of all 3 X 3 magic squares of distinct integers, primes, resp. consecutive primes. In all these, only the lexicographically smallest of the eight "equivalent" squares are listed. Note that the terms are not always in the order that corresponds to the terms of this sequence. For example, in row 3 of A320871 and row 11 of A320873, the second term is smaller than the third term. However, when this is not the case, then row n of the present sequence is the list of indices which gives the n-th variant of the square from the (ordered) set of 9 elements: e.g., (2, 7, 6, ...) means that the 2nd, 7th and 6th of the set of 9 numbers yield the first row of the square. For example, A320873(n) = A073519(a(n)), 1 <= n <= 9. - M. F. Hasler, Nov 04 2018

Examples

			The first such magic square is
2, 7, 6
9, 5, 1
4, 3, 8
From _M. F. Hasler_, Sep 23 2018: (Start)
The complete table reads:
[2, 7, 6, 9, 5, 1, 4, 3, 8]
[2, 9, 4, 7, 5, 3, 6, 1, 8]
[4, 3, 8, 9, 5, 1, 2, 7, 6]
[4, 9, 2, 3, 5, 7, 8, 1, 6]
[6, 1, 8, 7, 5, 3, 2, 9, 4]
[6, 7, 2, 1, 5, 9, 8, 3, 4]
[8, 1, 6, 3, 5, 7, 4, 9, 2]
[8, 3, 4, 1, 5, 9, 6, 7, 2] (End)
		

Crossrefs

Cf. A320871, A320872, A320873: inequivalent 3 X 3 magic squares of distinct integers, primes, consecutive primes.

Programs

  • Mathematica
    squares = {}; a=5; Do[m = {{a + b, a - b - c, a + c}, {a - b + c, a, a + b - c}, {a - c, a + b + c, a - b}}; If[ Unequal @@ Flatten[m] && And @@ (1 <= #1 <= 9 & ) /@ Flatten[m], AppendTo[ squares, m]], {b, -(a - 1), a - 1}, {c, -(a - 1), a - 1}]; Sort[ squares, FromDigits[ Flatten[#1] ] < FromDigits[ Flatten[#2] ] & ] // Flatten
  • PARI
    A217568=select(S->Set(S)==[1..9],concat(vector(9,a,vector(9,b,[a,b,15-a-b,20-2*a-b,5,2*a+b-10,a+b-5,10-b,10-a])))) \\ Could use that a = 2k, k = 1..4, and b is odd, within max(1,7-a)..min(9,13-a). - M. F. Hasler, Sep 23 2018

A320871 List of all inequivalent 3 X 3 magic squares made of distinct positive integers, sorted by increasing sum. For each equivalence class modulo symmetries of the square, the lexicographically smallest representative is shown.

Original entry on oeis.org

2, 7, 6, 9, 5, 1, 4, 3, 8, 2, 9, 7, 11, 6, 1, 5, 3, 10, 3, 7, 8, 11, 6, 1, 4, 5, 9, 3, 8, 7, 10, 6, 2, 5, 4, 9, 2, 11, 8, 13, 7, 1, 6, 3, 12, 3, 10, 8, 12, 7, 2, 6, 4, 11, 4, 8, 9, 12, 7, 2, 5, 6, 10, 4, 9, 8, 11, 7, 3, 6, 5, 10, 2, 13, 9, 15, 8, 1, 7, 3, 14, 3, 11, 10, 15, 8, 1, 6, 5, 13
Offset: 1

Views

Author

M. F. Hasler, Oct 28 2018

Keywords

Comments

"Symmetries of the square" means the symmetry group D4 consisting of reflections on any of the 4 symmetry axes of the square (horizontal H, vertical V, 2 diagonals D & A), which also generates the rotations around the center by multiples of 90°, R1, R2, R3 (and R0 = id): e.g., H o D = R1, where D means to transpose the 3 X 3 matrix, H means reversal of the rows, etc.
The 8 ("equivalent") variants of the first square are listed in A217568.

Examples

			The first five inequivalent magic squares (with magic sums 15, 18, 18, 18, 21) are
   [2 7 6]    [ 2 9  7]    [ 3 7 8]    [ 3 8 7]    [ 2 11  8]
   [9 5 1]    [11 6  1]    [11 6 1]    [10 6 2]    [13  7  1]
   [4 3 8]    [ 5 3 10]    [ 4 5 9]    [ 5 4 9]    [ 6  3 12]
They are listed as rows of the 9 elements of each square, so the first row is:
  [2, 7, 6; 9, 5, 1; 4, 3, 8],
the second row is:
  [2, 9, 7; 11, 6, 1; 5, 3, 10], and so on.
		

Crossrefs

Cf. A217568: the 8 equivalent variants of the first row.
Cf. A320872: subsequence of rows that consist only of primes; A268790 lists their magic sums with duplicates removed.
Cf. A320873: the first row that consists of a set of consecutive primes; it has magic sum = 4440084513 = A270305(1) = A073520(3).

Programs

  • PARI
    A320871_row(N=10,show_all=1,c=3)={for(c=c,oo, forstep(d=c-1,2,-1, for(b=max(2*d+1-c,1), d-1, d!=2*b&& S=[c-d,c+b,c+d-b;c+2*d-b,c,c-2*d+b;c-d+b,c-b,c+d]; !(show_all&&print(S))&& !N--&& return(S))))} \\ The third (optional) argument allows starting the list with the first square(s) having the central element >= c, i.e., magic sum >= 3c.
Showing 1-10 of 11 results. Next