A152137 Apparently an erroneous version of A073520.
2, 0, 4440084513, 258, 1703, 930
Offset: 1
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.
The magic square is [ 1480028201 1480028129 1480028183 ] [ 1480028153 1480028171 1480028189 ] [ 1480028159 1480028213 1480028141 ]
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
The magic square is [ 37 83 97 41 ] [ 53 61 71 73 ] [ 89 67 59 43 ] [ 79 47 31 101 ]
A073521=MagicPrimes(258,4) \\ See A073519 for MagicPrimes(). - M. F. Hasler, Oct 28 2018
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 ]
A073523=MagicPrimes(930,6) \\ See A073519 for MagicPrimes(). - M. F. Hasler, Oct 22 2018
The smallest magic square of order 4 has the constant of 258. See A073520 and A073521. The following array of 16 consecutive primes: 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103 also produces the magic square with the constant of K = 276: [ 41 37 97 101] [103 83 47 43] [ 71 67 79 59] [ 61 89 53 73] But then not every array of 16 consecutive primes produces a magic square. The next magic square can be made from the array (1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321): [1229 1249 1321 1319] [1301 1303 1231 1283] (K = 5118) [1297 1277 1307 1237] [1291 1289 1259 1279] Two more examples: [4943 4933 5011 5009] [12553 12583 12689 12653] [4999 4973 4967 4957] (K = 19896), [12641 12647 12601 12589] (K = 50478) [5003 4969 4987 4937] [12671 12611 12619 12577] [4951 5021 4931 4993] [12613 12637 12569 12659]
A173981(n, p=A260673[n], N=4)=sum(i=2, N^2, p=nextprime(p+1), p)/N \\ Illustration of the formula. - M. F. Hasler, Oct 28 2018
The first row of 9 terms, (1480028141, 1480028189, 1480028183, 1480028213, 1480028171, 1480028129, 1480028159, 1480028153, 1480028201), corresponds to the following smallest 3 X 3 magic square of consecutive primes: [1480028141 1480028189 1480028183] [1480028213 1480028171 1480028129] . [1480028159 1480028153 1480028201] The eleventh row yields the first example where the second term is smaller than the third one: [23813359643 23813359721 23813359727] [23813359781 23813359697 23813359613] . [23813359667 23813359673 23813359751]
A320873_row(n)=vecextract(n=MagicPrimes(3*A166113[n],3),[2,6+n=n[2]*2==n[1]+n[3],7-n,9,5,1,3+n,4-n,8]) \\ For MagicPrimes() see A073519 (the set of primes of the first row). /* the following allows the production of all 8 variants of a magic square that are equivalent modulo reflection on any of the 4 symmetry axes of the square */ REV(M)=matconcat(Vecrev(M)) \\ reverse the order of columns of M FLIP(M)=matconcat(Colrev(M)) \\ reverse the order of rows of M ALL(M,C(f,L)=concat(apply(f,L),L))=Set(C(REV,C(FLIP,[M,M~]))) \\ PARI orders the set according to the (first) columns of the matrices, so one must take the transpose to get them ordered according to elements of the first row.
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 ]
A073522=MagicPrimes(1703,5) \\ Cf. A073519. - M. F. Hasler, Oct 28 2018
A270305(n,p=A256891[n],N=3)=sum(i=2,N^2,p=nextprime(p+1),p)/N \\ Illustrates the second formula. Uses a precomputed array A256891, unless the smallest prime is supplied as optional 2nd argument. See also the 4x4 and 5x5 analog, A173981 and A176571, where this is useful for finding possible sets of primes, cf. A260673 and A272386. - M. F. Hasler, Oct 28 2018
Three examples of magic squares, which follow the one with the smallest constant. Array: 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 z = 2885, S = 577 59 61 127 179 151 107 131 167 83 89 173 149 67 79 109 101 139 103 163 71 137 97 113 73 157 Array: 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 z = 3515, S = 703 79 83 149 199 193 107 173 179 131 113 181 167 151 101 103 197 89 97 163 157 139 191 127 109 137 Array: 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 z = 3925, S = 785 97 101 149 211 227 199 179 163 107 137 109 197 167 173 139 223 127 113 191 131 157 181 193 103 151
A176571(n, p=A272386[n], N=5)=sum(i=2, N^2, p=nextprime(p+1), p)/N \\ Uses pre-computed array A272386, but can also be used to find these values: see there. - M. F. Hasler, Oct 30 2018
The square is [101 5 71 ; 29 59 89 ; 47 113 17]. The lexicographically smallest equivalent variant (modulo reflections on the symmetry axes of the square) is [17 89 71 ; 113 59 5 ; 47 29 101], cf. A320872. - _M. F. Hasler_, Oct 24 2018
A024351=select(p->setsearch(P,118-p),P=primes(30)[^5]) \\ 118 = 2*59, where 59 is the central prime; primes(30) = primes < 118. For the magic square itself, use A320872_row(1). - M. F. Hasler, Oct 25 2018
Comments