OFFSET
0,5
COMMENTS
Rearrangement of A054686.
For n >= 2, a(n) is the number of distinct positive slopes of least squares regression lines fitted to n points (j,y_j), 1 <= j <= n, where all y_j are 0 or 1. The total number of distinct slopes is 2*a(n)+1 (a(n) positive, a(n) negative, and the zero slope). - Pontus von Brömssen, Mar 10 2024
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (0,3,0,-3,0,1).
FORMULA
a(2*n) = n^2, a(2*n+1) = (n^2+n)/2.
From R. J. Mathar, Feb 12 2010: (Start)
a(n) = 3*a(n-2) - 3*a(n-4) + a(n-6).
G.f.: x^2*(1+x+x^2)/((1-x)^3*(1+x)^3). (End)
a(n) = (3*n^2-1+(n^2+1)*(-1)^n)/16. - Luce ETIENNE, May 30 2015
MATHEMATICA
CoefficientList[Series[x^2*(1+x+x^2)/((1-x)^3*(1+x)^3), {x, 0, 50}], x] (* or *) Table[(3*n^2-1+(n^2+1)*(-1)^n)/16, {n, 0, 50}] (* G. C. Greubel, Oct 26 2017 *)
With[{nn=30}, Riffle[Range[0, nn]^2, Accumulate[Range[0, nn]]]] (* or *) LinearRecurrence[{0, 3, 0, -3, 0, 1}, {0, 0, 1, 1, 4, 3}, 60] (* Harvey P. Dale, Feb 11 2020 *)
PROG
(PARI) {a(n) = if(n%2, (n^2-1)/8, n^2/4)} \\ Michael Somos, Nov 18 2006
(Magma) [(3*n^2-1+(n^2+1)*(-1)^n)/16: n in [0..10]]; // G. C. Greubel, Oct 26 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Hansen (babyskbaby(AT)web.de), Nov 14 2006
EXTENSIONS
Edited by Michael Somos, and several other correspondents, Nov 14 2005
STATUS
approved