[go: up one dir, main page]

login
A037488
Base 3 digits are, in order, the first n terms of the periodic sequence with initial period 2,1.
0
2, 7, 23, 70, 212, 637, 1913, 5740, 17222, 51667, 155003, 465010, 1395032, 4185097, 12555293, 37665880, 112997642, 338992927, 1016978783, 3050936350, 9152809052, 27458427157, 82375281473, 247125844420, 741377533262
OFFSET
1,1
FORMULA
a(n) = 3*a(n-1) + a(n-2) - 3*a(n-3).
G.f.: x*(2+x)/((1-x^2)*(1-3*x)). - Michael Somos, Sep 28 2002
a(n) = (7*3^n-(-1)^n-6)/8. - Bruno Berselli, Jan 20 2011
MATHEMATICA
Module[{nn=30, c}, c=PadRight[{}, nn, {2, 1}]; Table[FromDigits[Take[c, n], 3], {n, nn}]] (* or *) LinearRecurrence[{3, 1, -3}, {2, 7, 23}, 30] (* Harvey P. Dale, May 21 2015 *)
PROG
(PARI) a(n)=if(n<1, 0, 3*a(n-1)+1+n%2)
(PARI) a(n)=if(n<1, 0, 3^n*7\8)
CROSSREFS
Sequence in context: A048496 A369840 A210581 * A129669 A037568 A076656
KEYWORD
nonn,base,easy
STATUS
approved