OFFSET
0,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..5000
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
a(n) = 2*n -(1+(-1)^n)/2 if n>=1. - Frank Ellermann, Feb 12 2002
a(n) = A042964(n), n>0. - R. J. Mathar, Oct 13 2008
a(n) = A014601(n) - 1 for n>0. - Hugo Pfoertner, Oct 26 2020
MAPLE
A053438 := proc(n)
if n > 0 then
2*n -(1+(-1)^n)/2 ;
else
1 ;
end if
end proc:
seq(A053438(n), n=0..30) ; # R. J. Mathar, Oct 27 2020
MATHEMATICA
CoefficientList[Series[(1+x+2*x^3)/((1-x)*(1-x^2)), {x, 0, 50}], x] (* or *) Join[{1}, LinearRecurrence[{1, 1, -1}, {2, 3, 6}, 50]] (* G. C. Greubel, May 26 2018 *)
PROG
(PARI) a(n)=abs(n\2*4+n%2*3-1) \\ Charles R Greathouse IV, Dec 08 2011
(Magma) I:=[2, 3, 6]; [1] cat [n le 3 select I[n] else Self(n-1) +Self(n-2) -Self(n-3): n in [1..30]]; // G. C. Greubel, May 26 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Jan 12 2000
STATUS
approved