OFFSET
1,1
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (4,0,1,-4).
FORMULA
G.f.: x*(2+x+3*x^2) / ( (x-1)*(4*x-1)*(1+x+x^2) ). - R. J. Mathar, Nov 21 2011
a(n) = 4*a(n-1) + a(n-3) - 4*a(n-4). - Vincenzo Librandi, Jun 17 2012
a(n) = floor(13*4^n/21). - Christian Krause, Jun 05 2026
E.g.f.: exp(-x/2)*(-14*exp(3*x/2) + 13*exp(9*x/2) + cos(sqrt(3)*x/2) + 3*sqrt(3)*sin(sqrt(3)*x/2))/21. - Stefano Spezia, Jun 05 2026
MATHEMATICA
LinearRecurrence[{4, 0, 1, -4}, {2, 9, 39, 158}, 40] (* Vincenzo Librandi, Jun 17 2012 *)
(* Alternative: *)
Table[FromDigits[PadRight[{}, n, {2, 1, 3}], 4], {n, 30}] (* Harvey P. Dale, Jan 01 2026 *)
PROG
(Magma) I:=[2, 9, 39, 158]; [n le 4 select I[n] else 4*Self(n-1)+Self(n-3)-4*Self(n-4): n in [1..30]]; // Vincenzo Librandi, Jun 17 2012
(PARI) a(n)=([0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1; -4, 1, 0, 4]^(n-1)*[2; 9; 39; 158])[1, 1] \\ Charles R Greathouse IV, Jun 02 2026
CROSSREFS
KEYWORD
nonn,base,easy,changed
AUTHOR
EXTENSIONS
a(24)-a(27) from Christian Krause, Jun 05 2026
STATUS
approved
