OFFSET
0,3
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
G.f.: (1-2*x+3*x^2)/((1-x^2)*(1-x)).
a(n) = (2*n-1)/2 + 3*(-1)^n/2.
a(n) = 2*(n-1) - a(n-1), with a(0)=1. - Vincenzo Librandi, Nov 16 2010
a(n) = n - 2 + 3*((n-1) mod 2). - Lechoslaw Ratajczak, May 21 2021
a(n) = a(n-1)+a(n-2)-a(n-3). - Wesley Ivan Hurt, May 21 2021
MATHEMATICA
LinearRecurrence[{1, 1, -1}, {1, -1, 3}, 100] (* Amiram Eldar, May 21 2021 *)
With[{nn=91}, Riffle[Range[1, nn, 2], Range[-1, nn-2, 2]]] (* Harvey P. Dale, Jan 23 2023 *)
PROG
(Haskell)
import Data.List (transpose)
a097062 n = a097062_list !! n
a097062_list = concat $ transpose [a005408_list, (-1) : a005408_list]
-- Reinhard Zumkeller, Apr 16 2015
(PARI) a(n)=(2*n-1)/2+3*(-1)^n/2 \\ Charles R Greathouse IV, Oct 07 2015
(PARI) Vec((1-2*x+3*x^2)/((1-x^2)*(1-x)) + O(x^100)) \\ Altug Alkan, Nov 13 2015
(Magma) [(2*n-1)/2 + 3*(-1)^n/2 : n in [0..100]]; // Wesley Ivan Hurt, May 22 2021
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Paul Barry, Jul 22 2004
STATUS
approved