%I #46 Oct 04 2024 10:02:14
%S 0,4,13,29,54,90,139,203,284,384,505,649,818,1014,1239,1495,1784,2108,
%T 2469,2869,3310,3794,4323,4899,5524,6200,6929,7713,8554,9454,10415,
%U 11439,12528,13684,14909,16205,17574,19018,20539,22139,23820,25584
%N a(n) = n^2 + a(n-1), with a(1)=0.
%C Sum of the first n perfect squares (A000330), minus 1.
%H Reinhard Zumkeller, <a href="/A168559/b168559.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (4,-6,4,-1).
%F a(n) = n^3/3 + n^2/2 + n/6 - 1. - _Gary Detlefs_, Jun 30 2010
%F For n>1, a(n) = 2^2 + 3^2 + ... + n^2. - _Washington Bomfim_, Feb 15 2011
%F G.f.: x*(4-3*x+x^2)/(1-x)^4. - _Colin Barker_, Feb 03 2012
%F a(n) = A000330(n) - 1. - _Reinhard Zumkeller_, Feb 03 2012
%F a(n) = 4*a(n-1) - 6*a(n-2) + 4*a(n-3) - a(n-4) with a(1)=0, a(2)=4, a(3)=13, a(4)=29. - _Harvey P. Dale_, Dec 07 2013
%t k=-1;lst={};Do[k=n^2+k;AppendTo[lst,k],{n,5!}];lst (* _Vladimir Joseph Stephan Orlovsky_, Dec 05 2009 *)
%t RecurrenceTable[{a[1]==0,a[n]==n^2+a[n-1]},a,{n,50}] (* or *) LinearRecurrence[{4,-6,4,-1},{0,4,13,29},50] (* _Harvey P. Dale_, Dec 07 2013 *)
%t Accumulate[Range[50]^2] - 1 (* _Paolo Xausa_, Oct 04 2024 *)
%o (Haskell)
%o a168559 n = a168559_list !! (n-1)
%o a168559_list = scanl (+) 0 $ drop 2 a000290_list
%o -- _Reinhard Zumkeller_, Feb 03 2012
%o (PARI) a(n)=n^3/3+n^2/2+n/6-1 \\ _Charles R Greathouse IV_, Oct 16 2015
%Y Cf. A000330, A000290.
%K nonn,easy
%O 1,2
%A _Vincenzo Librandi_, Nov 30 2009