%I #25 Sep 08 2022 08:45:49
%S 2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,
%T -1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,
%U 2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1
%N Period 2: repeat 2, -1.
%C Interleaving of A007395 and -A000012.
%C Binomial transform of 2 followed by a signed version of A007283; also binomial transform of a signed version of A042950.
%C Second binomial transform of a signed version of A007051 without initial term 1.
%C Inverse binomial transform of 2 followed by A000079.
%C A028242 without first two terms gives partial sums.
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,1).
%F a(n) = (1 - 3*(-1)^n)/2.
%F a(n) = -a(n-1) + 1 for n > 1; a(1) = 2.
%F a(n) = a(n-2) for n > 2; a(1) = 2, a(2) = -1.
%F a(n+1) - a(n) = 3*(-1)^n.
%F G.f.: x*(2 - x)/((1-x)*(1+x)).
%F E.g.f.: (1/2)*(-1 + exp(x))*(3 + exp(x))*exp(-x). - _G. C. Greubel_, Jul 19 2016
%t PadRight[{},120,{2,-1}] (* _Harvey P. Dale_, Jan 04 2015 *)
%t Table[(1 - 3 (-1)^n)/2, {n, 120}] (* or *)
%t Rest@ CoefficientList[Series[x (2 - x)/((1 - x) (1 + x)), {x, 0, 120}], x] (* _Michael De Vlieger_, Jul 19 2016 *)
%o (Magma) &cat[ [2, -1]: n in [1..42] ];
%o [ n eq 1 select 2 else -Self(n-1)+1: n in [1..84] ];
%o (PARI) a(n)=2-n%2*3 \\ _Charles R Greathouse IV_, Jul 13 2016
%o (Magma) &cat[[2,-1]^^40]; // _Vincenzo Librandi_, Jul 20 2016
%Y Cf. A168330 (repeat 3, -2), A007395 (all 2's sequence), A000012 (all 1's sequence), (A007283 3*2^n), A042950, A007051 ((3^n+1)/2), A000079 (powers of 2), A028242 (follow n+1 by n).
%K sign,easy
%O 1,1
%A _Klaus Brockhaus_, Nov 23 2009
%E G.f. adapted to the offset by _Bruno Berselli_, Apr 01 2011