OFFSET
0,2
COMMENTS
The reversible magic squares are in a one-to-one correspondence with the most-perfect pandiagonal magic squares (cf. A051235).
A reversible magic square composed of integers {0,1,...,n^2-1} is principal if its rows and columns form increasing sequences and the first row starts with 0, 1.
Every reversible magic square can be transformed into a unique principal square by (i) interchanging a row/column with the symmetric row/column; and (ii) interchanging two rows/columns in one half of the square and simultaneously interchange their symmetric rows/columns in the other half.
REFERENCES
K. Ollerenshaw and D. S. Bree, Most-perfect Pan-diagonal Magic Squares: Their Construction and Enumeration, Inst. Math. Applic., Southend-on-Sea, England, 1998.
I. Stewart, Most-perfect magic squares, Sci. Amer., Vol. 281, No. 5 (Nov. 1999), pp. 122-123.
LINKS
Max Alekseyev, Table of n, a(n) for n = 0..10000
Steve Abbott, Review of Most-perfect Pan-diagonal Magic Squares: Their Construction and Enumeration by Kathleen Ollerenshaw and David Brée, The Mathematical Gazette, Volume 82, Issue 495 November 1998, pp. 535-536.
FORMULA
For n>=1, let N := 4n = Product_{g} (p_g)^(s_g), where p_g are distinct primes, and W_v(n) := Sum_{i=0..v} (-1)^(v+i) * binomial(v+1,i+1) * Product_{g} binomial(s_g+i,i). Then a(n) = Sum_{v=0..Sum_{g} s_g} W_v(N)*(W_v(N)+W_{v+1}(N)).
For n>=1, a(n) = A051235(n) / 2^(4*n-2) / (2n)!^2.
MATHEMATICA
a[n_] := Module[{s, W}, If[n == 0, Return[1]]; s = FactorInteger[4 n][[All, 2]]; W = Table[Sum[(-1)^(V - i - 1) Binomial[V, i + 1] Product[ Binomial[ s[[g]] + i, i], {g, 1, Length[s]}], {i, 0, V - 1}], {V, 1, Total[s] + 1}]; Sum[W[[V]] (W[[V]] + W[[V+1]]), {V, 1, Length[W]-1}]];
Table[a[n], {n, 0, 62}] (* Jean-François Alcover, Jul 03 2019, translated from PARI *)
PROG
(PARI) { A308951(n) = if(n==0, return(1)); my(s=factor(4*n)[, 2], W=vector(vecsum(s)+1, V, sum(i=0, V-1, (-1)^(V-i-1) * binomial(V, i+1) * prod(g=1, #s, binomial(s[g]+i, i)) ))); sum(V=1, #W-1, W[V]*(W[V]+W[V+1])); }
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Max Alekseyev, Jul 02 2019
STATUS
approved