OFFSET
1,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (4,2,-1).
FORMULA
a(n) = 4*a(n-1) + 2*a(n-2) - a(n-3).
G.f.: x*(1-x)/(1-4*x-2*x^2+x^3). - Colin Barker, May 25 2013
MAPLE
a:= n-> (<<3|2|1>, <2|1|0>, <1|0|0>>^n)[1, 3]:
seq(a(n), n=1..30); # Alois P. Heinz, May 25 2013
MATHEMATICA
LinearRecurrence[{4, 2, -1}, {1, 3, 14}, 40] (* G. C. Greubel, Feb 05 2023 *)
PROG
(Magma) I:=[1, 3, 14]; [n le 3 select I[n] else 4*Self(n-1) +2*Self(n-2) -Self(n-3): n in [1..40]]; // G. C. Greubel, Feb 05 2023
(SageMath)
@CachedFunction
def a(n): # a = A100296
if (n<3): return (0, 1, 3)[n]
else: return 4*a(n-1) + 2*a(n-2) - a(n-3)
[a(n) for n in range(1, 41)] # G. C. Greubel, Feb 05 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Gary W. Adamson, Nov 11 2004
EXTENSIONS
More terms from Colin Barker, May 25 2013
New name using g.f. from Joerg Arndt, Aug 31 2024
STATUS
approved