OFFSET
1,5
COMMENTS
Contribution from Thomas Zaslavsky, Mar 12 2010: (Start)
A magic square has distinct positive integers in its cells, whose sum is the same (the "magic sum") along any row, column, or main diagonal.
a(n) is given by a quasipolynomial of period 6. (End)
LINKS
T. Zaslavsky, Table of n, a(n) for n = 1..10000.
M. Beck and T. Zaslavsky, An enumerative geometry for magic and magilatin labellings, Ann. Combinatorics, 10 (2006), no. 4, 395-413. MR 2007m:05010. Zbl 1116.05071. - Thomas Zaslavsky, Jan 29 2010
Matthias Beck and Thomas Zaslavsky, Six Little Squares and How their Numbers Grow, Journal of Integer Sequences, 13 (2010), Article 10.6.2.
Index entries for linear recurrences with constant coefficients, signature (1,1,0,-1, -1,1).
FORMULA
G.f.: [8*x^5*(1+2*x)] / [(1-x)*(1-x^2)*(1-x^3)].
a(n) = a(n-1) + a(n-2) - a(n-4) - a(n-5) + a(n-6). - Vincenzo Librandi, Sep 01 2018
EXAMPLE
a(5) = 8 because there are 8 3 X 3 magic squares with entries 1,...,9 and magic sum 15.
MATHEMATICA
LinearRecurrence[{1, 1, 0, -1, -1, 1}, {0, 0, 0, 0, 8, 24}, 50] (* Jean-François Alcover, Sep 01 2018 *)
CoefficientList[Series[8 x^4 (1 + 2 x) / ((1 - x) (1 - x^2) (1 - x^3)), {x, 0, 50}], x] (* Vincenzo Librandi, Sep 01 2018 *)
PROG
(PARI) a(n)=(1/9)*(2*n^2-32*n+[144, 78, 120, 126, 96, 102][(n%18)/3+1])
(PARI) x='x+O('x^99); concat(vector(4), Vec(8*x^5*(1+2*x)/((1-x)*(1-x^2)*(1-x^3)))) \\ Altug Alkan, Sep 01 2018
(Magma) I:=[0, 0, 0, 0, 8, 24]; [n le 6 select I[n] else Self(n-1)+Self(n-2)-Self(n-4)-Self(n-5)+Self(n-6): n in [1..60]]; // Vincenzo Librandi, Sep 01 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Zaslavsky and Ralf Stephan, Jun 11 2005
EXTENSIONS
Edited by N. J. A. Sloane, Feb 05 2010
Corrected g.f. to account for previous change in parameter n from magic sum s to s/3; by Thomas Zaslavsky, Mar 12 2010
STATUS
approved