A168361 Period 2: repeat 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, 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, 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
Offset: 1
Links
- Index entries for linear recurrences with constant coefficients, signature (0,1).
Crossrefs
Programs
-
Magma
&cat[ [2, -1]: n in [1..42] ]; [ n eq 1 select 2 else -Self(n-1)+1: n in [1..84] ];
-
Magma
&cat[[2,-1]^^40]; // Vincenzo Librandi, Jul 20 2016
-
Mathematica
PadRight[{},120,{2,-1}] (* Harvey P. Dale, Jan 04 2015 *) Table[(1 - 3 (-1)^n)/2, {n, 120}] (* or *) Rest@ CoefficientList[Series[x (2 - x)/((1 - x) (1 + x)), {x, 0, 120}], x] (* Michael De Vlieger, Jul 19 2016 *)
-
PARI
a(n)=2-n%2*3 \\ Charles R Greathouse IV, Jul 13 2016
Formula
a(n) = (1 - 3*(-1)^n)/2.
a(n) = -a(n-1) + 1 for n > 1; a(1) = 2.
a(n) = a(n-2) for n > 2; a(1) = 2, a(2) = -1.
a(n+1) - a(n) = 3*(-1)^n.
G.f.: x*(2 - x)/((1-x)*(1+x)).
E.g.f.: (1/2)*(-1 + exp(x))*(3 + exp(x))*exp(-x). - G. C. Greubel, Jul 19 2016
Extensions
G.f. adapted to the offset by Bruno Berselli, Apr 01 2011
Comments