OFFSET
0,5
COMMENTS
Given an order-n magic square with n >= 4, the least number of cells that can be changed to create a new square with all sums of rows, columns, and diagonals preserved is four; the four changed cells must correspond to the vertices of one of these a(n) rectangles. Of course the same sum-preserving property occurs in these cases even when the original n X n square of numbers is not a magic square. Perhaps curiously at first glance, a 3 X 3 (magic) square requires at least six cells to be changed to preserve all the sums (reflection in the central row, column, or either diagonal has the same effect as changing exactly six cells).
FORMULA
Conjectures from Colin Barker, May 03 2017: (Start)
G.f.: 2*x^4*(1 + 3*x + 3*x^2 + 17*x^3) / ((1 - x)^5*(1 + x)^3).
a(n) = (n^4 - 10*n^3 + 33*n^2 - 34*n) / 4 for n even.
a(n) = (n^4 - 10*n^3 + 37*n^2 - 58*n + 30) / 4 for n odd.
a(n) = 2*a(n-1) + 2*a(n-2) - 6*a(n-3) + 6*a(n-5) - 2*a(n-6) - 2*a(n-7) + a(n-8) for n>7.
(End)
PROG
(PARI) {a(n)= my(c = 0, np1 = n + 1);
for(i1 = 1, n - 1, for(i2 = i1 + 1, n, for(j1 = 1, n - 1,
if(i1 == j1 || i1 + j1 == np1 || i2 == j1 || i2 + j1 == np1,
continue,
for(j2 = j1 + 1, n,
if(i1 <> j2 && i1 + j2 <> np1 &&
i2 <> j2 && i2 + j2 <> np1, c++)))))); c}
CROSSREFS
KEYWORD
nonn
AUTHOR
Rick L. Shepherd, Apr 29 2017
STATUS
approved