OFFSET
0,2
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..2000
Index entries for linear recurrences with constant coefficients, signature (1,3,-3).
FORMULA
From Hieronymus Fischer, Sep 19 2007, formulas adjusted to offset, Dec 29 2012: (Start)
G.f.: (1+2*x)/((1-3*x^2)*(1-x)).
a(n) = (3/2)*(3^((n+1)/2)-1) if n is odd, else a(n) = (3/2)*(5*3^((n-2)/2)-1).
a(n) = (3/2)*(3^floor((n+1)/2) + 3^floor(n/2) - 3^floor((n-1)/2)-1).
a(n) = 3^floor((n+1)/2) + 3^floor((n+2)/2)/2 - 3/2.
a(n) = A132667(a(n+1)) - 1.
a(n) = A132667(a(n-1) + 1) for n > 0.
A132667(a(n)) = a(n-1) + 1 for n > 0.
Also numbers such that: a(0)=1, a(n) = a(n-1) + (p-1)*p^((n+1)/2 - 1) if n is odd, else a(n) = a(n-1) + p^(n/2), where p=3. (End)
MAPLE
A087503 := proc(n)
option remember;
if n <=1 then
op(n+1, [1, 3]) ;
else
3*procname(n-2)+3 ;
end if;
end proc:
seq(A087503(n), n=0..20) ; # R. J. Mathar, Sep 10 2021
MATHEMATICA
RecurrenceTable[{a[0]==1, a[1]==3, a[n]==3(a[n-2]+1)}, a, {n, 40}] (* Harvey P. Dale, Jan 01 2015 *)
(* Alternative: *)
LinearRecurrence[{1, 3, -3}, {1, 3, 6}, 40] (* Harvey P. Dale, Jan 01 2015 *)
PROG
(Magma) [(3/2)*(3^Floor((n+1)/2)+3^Floor(n/2)-3^Floor((n-1)/2)-1): n in [0..40]]; // Vincenzo Librandi, Aug 16 2011
(Python)
def A087503(n): return (3+((n+1&1)<<1))*3**(n+1>>1)-3>>1 # Chai Wah Wu, Sep 02 2025
CROSSREFS
KEYWORD
nonn,easy,changed
AUTHOR
Reinhard Zumkeller, Sep 11 2003
EXTENSIONS
Additional comments from Hieronymus Fischer, Sep 19 2007
Edited by N. J. A. Sloane, May 04 2010. I merged two essentially identical entries with different offsets, so some of the formulas may need to be adjusted.
Formulas and MAGMA prog adjusted to offset 0 by Hieronymus Fischer, Dec 29 2012
STATUS
approved
