OFFSET
1,3
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,2,0,-1).
FORMULA
G.f.: x*(3*x^2+x+1) / ((x-1)^2*(x+1)^2). [Colin Barker, Feb 18 2013]
From Wesley Ivan Hurt, Dec 06 2015: (Start)
a(n) = 2*a(n-2)-a(n-4) for n>4.
a(n) = n - Sum_{i=1..n} ceiling( (-1)^i*(2*n-3+i)/2 ). (End)
MAPLE
a:=proc(n) option remember; if n=1 then 1 elif n=2 then 1 elif n=3 then 5 elif n=4 then 2 else 2*a(n-2)-a(n-4); fi; end: seq(a(n), n=1..100); # Wesley Ivan Hurt, Dec 06 2015
MATHEMATICA
CoefficientList[Series[(3*x^2 + x + 1)/(x^2 - 1)^2, {x, 0, 100}], x] (* or *) LinearRecurrence[{0, 2, 0, -1}, {1, 1, 5, 2}, 100] (* Wesley Ivan Hurt, Dec 06 2015 *)
PROG
(PARI) Vec(x*(3*x^2+x+1) / ((x-1)^2*(x+1)^2) + O(x^100)) \\ Michel Marcus, Dec 06 2015
(PARI) vector(100, n, n - sum(i=1, n, ceil((-1)^i*(2*n-3+i)/2 ))) \\ Altug Alkan, Dec 06 2015
(Magma) I:=[1, 1, 5, 2]; [n le 4 select I[n] else 2*Self(n-2)-Self(n-4) : n in [1..100]]; // Wesley Ivan Hurt, Dec 06 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Antti Karttunen, Oct 28 2001
STATUS
approved