OFFSET
1,2
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,6,0,-1).
FORMULA
a(n) = 6*a(n-2) - a(n-4) for n>4.
G.f.: x*(1+x)*(1+5*x+x^2) / ((1+2*x-x^2)*(1-2*x-x^2)).
a(n) = (1/4)*(5*P(n+1) - P(n) + (-1)^n*(P(n-1) + 5*P(n-2))), where P(n) = A000129(n). - G. C. Greubel, Sep 15 2021
EXAMPLE
6 is in the sequence because 6^2+9 = 45, which is a triangular number.
MATHEMATICA
CoefficientList[Series[(1+x)*(1+5*x+x^2)/((1+2*x-x^2)*(1-2*x-x^2)), {x, 0, 30}], x] (* Wesley Ivan Hurt, Sep 07 2016 *)
LinearRecurrence[{0, 6, 0, -1}, {1, 6, 12, 37}, 31] (* G. C. Greubel, Sep 15 2021 *)
PROG
(PARI) Vec(x*(1+x)*(1+5*x+x^2) / ((1+2*x-x^2)*(1-2*x-x^2)) + O(x^40))
(Magma) I:=[1, 6, 12, 37]; [n le 2 select I[n] else 6*Self(n-2) - Self(n-4): n in [1..31]]; // G. C. Greubel, Sep 15 2021
(Sage)
def P(n): return lucas_number1(n, 2, -1)
[(1/4)*(5*P(n+1) - P(n) + (-1)^n*(P(n-1) + 5*P(n-2))) for n in (1..30)] # G. C. Greubel, Sep 15 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Colin Barker, Sep 07 2016
STATUS
approved