%I #33 Mar 12 2024 23:40:35
%S 0,0,1,1,4,3,9,6,16,10,25,15,36,21,49,28,64,36,81,45,100,55,121,66,
%T 144,78,169,91,196,105,225,120,256,136,289,153,324,171,361,190,400,
%U 210,441,231,484,253,529,276,576,300,625,325,676,351,729,378,784,406,841,435
%N Squares alternating with triangular numbers.
%C Rearrangement of A054686.
%C 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
%H Alois P. Heinz, <a href="/A123596/b123596.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0,3,0,-3,0,1).
%F a(2*n) = n^2, a(2*n+1) = (n^2+n)/2.
%F From _R. J. Mathar_, Feb 12 2010: (Start)
%F a(n) = 3*a(n-2) - 3*a(n-4) + a(n-6).
%F G.f.: x^2*(1+x+x^2)/((1-x)^3*(1+x)^3). (End)
%F a(n) = (3*n^2-1+(n^2+1)*(-1)^n)/16. - _Luce ETIENNE_, May 30 2015
%t 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 *)
%t 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 *)
%o (PARI) {a(n) = if(n%2,(n^2-1)/8,n^2/4)} \\ _Michael Somos_, Nov 18 2006
%o (Magma) [(3*n^2-1+(n^2+1)*(-1)^n)/16: n in [0..10]]; // _G. C. Greubel_, Oct 26 2017
%Y Cf. A002620, A054686, A124093.
%K nonn
%O 0,5
%A Peter Hansen (babyskbaby(AT)web.de), Nov 14 2006
%E Edited by _Michael Somos_, and several other correspondents, Nov 14 2005