A320876 Lexicographically first 6 X 6 pandiagonal magic square made of consecutive primes with the smallest magic constant (930).
67, 139, 241, 73, 199, 211, 193, 233, 97, 167, 103, 137, 71, 113, 191, 131, 227, 197, 251, 181, 89, 229, 101, 79, 109, 157, 163, 151, 127, 223, 239, 107, 149, 179, 173, 83
Offset: 1
Examples
The magic square is [ 67 139 241 73 199 211] [193 233 97 167 103 137] [ 71 113 191 131 227 197] [251 181 89 229 101 79] [109 157 163 151 127 223] [239 107 149 179 173 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.
Links
Programs
-
PARI
/* the following transformation operators for matrices, together with transposition, allow the production of all variants of a (pandiagonal) magic square */ REV(M)=matconcat(Vecrev(M)) \\ reverse the order of columns of M FLIP(M)=matconcat(Colrev(M)) \\ reverse the order of row of M ROT(M,k=1)=matconcat([M[,k+1..#M],M[,1..k]]) \\ rotate left by k (default: 1) columns ALL(M)=Set(concat(apply(M->vector(#M,k,ROT(M,k)),[M,M~,REV(M),REV(M~),FLIP(M),FLIP(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. MagicPrimes(S=930,n=6,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 (= A073523 for default values), or a negative vector of "best approximation" if there is no exact solution.
Comments