%I #15 Jan 16 2019 19:42:07
%S 1,1,0,0,9,20,96,656,5584,48913,494264,5383552,65103875,840566080,
%T 11834159652,176621049784,2838040416201,48060623405312
%N Number of non-normal magic squares whose entries are all 0 or 1 and sum to n.
%C A non-normal magic square is a square matrix with row sums, column sums, and both diagonals all equal to d, for some d|n.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Magic_square">Magic square</a>
%H <a href="/index/Mag#magic">Index entries for sequences related to magic squares</a>
%F a(n) >= A007016(n) with equality if n is prime. - _Chai Wah Wu_, Jan 15 2019
%e The a(4) = 9 magic squares:
%e [1 1]
%e [1 1]
%e .
%e [1 0 0 0][1 0 0 0][0 1 0 0][0 1 0 0][0 0 1 0][0 0 1 0][0 0 0 1][0 0 0 1]
%e [0 0 1 0][0 0 0 1][0 0 1 0][0 0 0 1][1 0 0 0][0 1 0 0][1 0 0 0][0 1 0 0]
%e [0 0 0 1][0 1 0 0][1 0 0 0][0 0 1 0][0 1 0 0][0 0 0 1][0 0 1 0][1 0 0 0]
%e [0 1 0 0][0 0 1 0][0 0 0 1][1 0 0 0][0 0 0 1][1 0 0 0][0 1 0 0][0 0 1 0]
%t prs2mat[prs_]:=Table[Count[prs,{i,j}],{i,Union[First/@prs]},{j,Union[Last/@prs]}];
%t multsubs[set_,k_]:=If[k==0,{{}},Join@@Table[Prepend[#,set[[i]]]&/@multsubs[Drop[set,i-1],k-1],{i,Length[set]}]];
%t Table[Length[Select[Subsets[Tuples[Range[n],2],{n}],And[Union[First/@#]==Range[Max@@First/@#]==Union[Last/@#],SameQ@@Join[{Tr[prs2mat[#]],Tr[Reverse[prs2mat[#]]]},Total/@prs2mat[#],Total/@Transpose[prs2mat[#]]]]&]],{n,5}]
%Y Cf. A006052, A007016, A057151, A068313, A101370, A104602, A120732, A271103, A319056, A319616.
%Y Cf. A321717, A321718, A321719, A321720, A321721, A321722.
%K nonn,more
%O 0,5
%A _Gus Wiseman_, Nov 18 2018
%E a(7)-a(15) from _Chai Wah Wu_, Jan 15 2019
%E a(16)-a(17) from _Chai Wah Wu_, Jan 16 2019
|