login
A037632
Base 4 digits are, in order, the first n terms of the periodic sequence with initial period 2,1,3.
1
2, 9, 39, 158, 633, 2535, 10142, 40569, 162279, 649118, 2596473, 10385895, 41543582, 166174329, 664697319, 2658789278, 10635157113, 42540628455, 170162513822, 680650055289, 2722600221159, 10890400884638, 43561603538553, 174246414154215, 696985656616862, 2787942626467449, 11151770505869799
OFFSET
1,1
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
Sequence in context: A070017 A054129 A037737 * A095939 A361358 A151009
KEYWORD
nonn,base,easy,changed
EXTENSIONS
a(24)-a(27) from Christian Krause, Jun 05 2026
STATUS
approved