%I #42 Oct 27 2019 22:03:09
%S 2,0,4440084513,258,313,484,797,2016,2211,2862,4507,6188,6325,9660,
%T 12669,13016,16857,19530,23069,28184,38761,46302,42515,49846,59087,
%U 70260,73385,78960,97267,98316,111023,124454,134641,152952,163043,180596,195975,218432,237623,293182,276243,298868
%N Smallest magic constant for any n X n magic square made from consecutive primes, or 0 if no such magic square exists.
%D Allan W. Johnson, Jr., Journal of Recreational Mathematics, vol. 14:2, 1981-82, pp. 152-153.
%D Allan W. Johnson, Jr., Journal of Recreational Mathematics, vol. 23:3, 1991, pp. 190-191.
%D H. L. Nelson, Journal of Recreational Mathematics, 1988, vol. 20:3, p. 214.
%D Clifford A. Pickover, The Zen of Magic Squares, Circles and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002.
%H M. F. Hasler, <a href="/A073520/b073520.txt">Table of n, a(n) for n = 1..63</a>
%H Mutsumi Suzuki, <a href="http://web.archive.org/web/20011122031722/http://www.pse.che.tohoku.ac.jp/~msuzuki/MagicSquare.prime.seq.html">Study of Magic Squares</a>, 1957, in Japanese. Gives minimal squares of orders from 4 to 9 composed of consecutive primes.
%H Harvey Heinz, <a href="http://www.magic-squares.net/primesqr.htm">Prime Magic Squares</a>
%H N. Makarova <a href="http://dxdy.ru/post244835.html#p244835">Squares 7x7, 8x8, 9x9</a>, <a href="http://dxdy.ru/post244886.html#p244886">Squares 10x10, 11x11, 12x12</a>, <a href="http://dxdy.ru/post244987.html#p244987">Square 14x14</a> (in Russian)
%H Stefano Tognon, <a href="http://digilander.libero.it/ice00/magic/prime/orderConstant.html">Table for prime magic squares</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimeMagicSquare.html">Prime Magic Square</a>
%H <a href="/index/Mag#magic">Index entries for sequences related to magic squares</a>
%F 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.
%F 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
%F In the above, A049084 could be replaced by A000720 = primepi. - _M. F. Hasler_, Oct 29 2018
%e A square of order 15 found by _Natalia Makarova_, communicated by Stefano Tognon, Sep 23 2009:
%e [ 131 167 229 461 541 617 733 911 967 1091 1259 1279 1319 1471 1493
%e 547 907 1583 1613 149 1423 193 1601 941 137 233 389 1039 1283 631
%e 1019 181 751 163 1453 1301 1297 1277 271 1619 1327 691 277 281 761
%e 1307 719 359 919 1063 653 1237 269 1433 863 1439 313 191 1021 883
%e 503 1367 433 1013 829 1153 317 347 1109 491 1249 677 1451 1489 241
%e 421 311 1487 439 1049 1409 1123 463 409 983 449 1031 1163 373 1559
%e 1399 1193 419 1531 971 647 977 1051 709 479 1229 379 353 1093 239
%e 599 953 1213 587 499 727 1321 787 307 1151 157 1571 1033 773 991
%e 211 1291 1499 577 1087 349 947 467 739 613 1171 1609 173 839 1097
%e 563 139 1373 1459 1289 443 619 1201 1427 809 881 1303 331 263 569
%e 607 1607 1511 673 1181 1481 1217 523 661 857 223 743 197 431 757
%e 853 643 701 179 1483 571 769 859 1447 659 929 997 1223 1129 227
%e 1549 887 257 557 367 1061 601 337 1361 937 1231 811 1543 293 877
%e 1579 1187 397 1069 509 683 797 1567 401 383 641 283 823 827 1523
%e 1381 1117 457 1429 199 151 521 1009 487 1597 251 593 1553 1103 821]
%o (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
%Y Cf. A104157: smallest element in an n X n magic squares of consecutive primes.
%Y 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).
%Y Cf. A256234: magic sums of 4 X 4 pandiagonal magic squares of consecutive primes.
%K nonn,nice
%O 1,1
%A _N. J. A. Sloane_, Aug 29 2002
%E 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
%E a(15) from _Natalia Makarova_, a(16) and further terms from Stefano Tognon
%E Edited by _Max Alekseyev_, Oct 13 2009
%E Edited and more terms (using A104157) from _M. F. Hasler_, Oct 29 2018