OFFSET
0,2
COMMENTS
LINKS
Robert Israel, Table of n, a(n) for n = 0..3318
Index entries for linear recurrences with constant coefficients, signature (-1,1,-2).
FORMULA
a(0)=1, a(1)=-2, a(2)=3, a(n) = -a(n-1) + a(n-2) - 2*a(n-3). - Harvey P. Dale, Feb 02 2012 [corrected by Wojciech Florek, Feb 26 2018]
a(n) = (1/21) * (-9*2^n*e^(i*n*Pi) + 9*cos((n*Pi)/3) - sqrt(3)*sin((n*Pi)/3)). - Harvey P. Dale, Feb 02 2012
a(n) = (1/7) * (6*(-2)^n + [1,-2,-3,-1,2,3](mod 6)) = A077972(n) - A077972(n-1). - Ralf Stephan, Aug 18 2013
a(n) = floor((6*(-2)^n+3)/7). - Tani Akinari, Oct 05 2014
MAPLE
f:= gfun:-rectoproc({a(0)=1, a(1)=-2, a(2)=3, a(n) = -a(n-1) + a(n-2) - 2*a(n-3)}, a(n), remember):
map(f, [$0..40]); # Robert Israel, Mar 28 2018
MATHEMATICA
CoefficientList[Series[(1-x)/(1+x-x^2+2x^3), {x, 0, 40}], x] (* or *) LinearRecurrence[{-1, 1, -2}, {1, -2, 3}, 40] (* Harvey P. Dale, Feb 02 2012 *)
PROG
(PARI) Vec((1-x)/(1+x-x^2+2*x^3)+O(x^99)) \\ Charles R Greathouse IV, Sep 26 2012
(PARI) a(n)=1/7*(6*(-2)^n+[1, -2, -3, -1, 2, 3][(n%6)+1]) /* Ralf Stephan, Aug 18 2013 */
(PARI) a(n)=(6*(-2)^n+3)\7 \\ Tani Akinari, Oct 05 2014
CROSSREFS
KEYWORD
sign,easy
AUTHOR
N. J. A. Sloane, Nov 17 2002
STATUS
approved