login
a(0)=0, a(1)=1, a(2)=2 and a(n) = a(n-1) - 2a(n-2) + a(n-3).
1

%I #16 Apr 26 2016 19:47:10

%S 0,1,2,0,-3,-1,5,4,-7,-10,8,21,-5,-39,-8,65,42,-96,-115,119,253,-100,

%T -487,-34,840,421,-1293,-1295,1712,3009,-1710,-6016,413,10735,3893,

%U -17164,-14215,24006,35272,-26955,-73493,15689,135720,30849,-224902

%N a(0)=0, a(1)=1, a(2)=2 and a(n) = a(n-1) - 2a(n-2) + a(n-3).

%H Alois P. Heinz, <a href="/A166117/b166117.txt">Table of n, a(n) for n = 0..1000</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,-2,1).

%F a(n) = n for n<3, else a(n) = a(n-1) - 2*a(n-2) + a(n-3).

%F G.f.: -(x+1)*x/(x^3-2*x^2+x-1). - _Alois P. Heinz_, Sep 30 2013

%F a(n) = (-1)^(1+n)*A078051(n-1). - _R. J. Mathar_, Feb 05 2016

%e a(0)=0, a(1)=1, a(2)=2, a(3) = 2-2(1)+0 = 0, a(4)= 0-2(2)+ 1 = -3, a(5) = -3 -2(0) + 2 = -1, a(6)= -1 -2(-3)+ 0 = 5.

%p a:= proc(n) a(n):=`if`(n<3, n, a(n-1)-2*a(n-2)+a(n-3)) end:

%p seq(a(n), n=0..50); # _Alois P. Heinz_, Sep 30 2013

%t LinearRecurrence[{1, -2, 1}, {0, 1, 2}, 10] (* _G. C. Greubel_, Apr 26 2016 *)

%Y Cf. A078051.

%K sign,easy

%O 0,3

%A Barry Wells (wells.barry(AT)gmail.com), Oct 06 2009