OFFSET
1,1
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,3,0,-3,0,1).
FORMULA
For even n, a(n) = n^2/2 + 2n - 2. For odd n, a(n) = n^2 + 2n - 1. - Eric M. Schmidt, Apr 20 2013
From Colin Barker, Feb 24 2017: (Start)
a(n) = 3*a(n-2) - 3*a(n-4) + a(n-6) for n>6.
G.f.: 2*x*(1 + 2*x + 4*x^2 + x^3 - x^4 - x^5) / ((1 - x)^3*(1 + x)^3).
(End)
MATHEMATICA
Table[If[EvenQ[n], n^2/2+2n-2, n^2+2n-1], {n, 100}] (* or *) LinearRecurrence[ {0, 3, 0, -3, 0, 1}, {2, 4, 14, 14, 34, 28}, 80] (* Harvey P. Dale, Dec 15 2018 *)
PROG
(Sage) def A087420(n) : return n^2//2 + 2*n - 2 if is_even(n) else n^2 + 2*n - 1 # Eric M. Schmidt, Apr 20 2013
(PARI) Vec(2*x*(1 + 2*x + 4*x^2 + x^3 - x^4 - x^5) / ((1 - x)^3*(1 + x)^3) + O(x^70)) \\ Colin Barker, Feb 24 2017
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Yuval Dekel (dekelyuval(AT)hotmail.com), Oct 22 2003
EXTENSIONS
More terms from Eric M. Schmidt, Apr 20 2013
STATUS
approved