login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A079362 Sequence of sums of alternating powers of 3. 2

%I #24 Sep 08 2022 08:45:08

%S 1,4,5,14,17,44,53,134,161,404,485,1214,1457,3644,4373,10934,13121,

%T 32804,39365,98414,118097,295244,354293,885734,1062881,2657204,

%U 3188645,7971614,9565937,23914844,28697813,71744534,86093441,215233604

%N Sequence of sums of alternating powers of 3.

%H G. C. Greubel, <a href="/A079362/b079362.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,3,-3).

%F G.f.: x*(1+3*x-2*x^2)/((1-x)*(1-3*x^2)). - _Michael Somos_, Feb 18 2003

%F For n >= 1, a(2n-1) = (2/3)*3^n - 1, a(2n) = (5/3)*3^n - 1. - _Benoit Cloitre_, Feb 16 2003

%p a[1]:=1:a[2]:=4:for n from 3 to 100 do a[n]:=3*a[n-2]+2 od: seq(a[n], n=1..33); # _Zerinvary Lajos_, Mar 17 2008

%t LinearRecurrence[{1,3,-3},{1,4,5},40] (* _Harvey P. Dale_, Oct 18 2016 *)

%o (PARI) a(n)=if(n<1,0,1+sum(k=2,n,3^((k\2)-(k%2))))

%o (PARI) a(n)=if(n<0,0,(5/3-3*n%2)*2^ceil(n/2)-1)

%o (Magma) I:=[1,4,5]; [n le 3 select I[n] else Self(n-1) +3*Self(n-2) -3*Self(n-3): n in [1..40]]; // _G. C. Greubel_, Aug 07 2019

%o (Sage)

%o @CachedFunction

%o def a(n):

%o if (n==0): return 1

%o elif (1<=n<=2): return n+3

%o else: return a(n-1) + 3*a(n-2) - 3*a(n-3)

%o [a(n) for n in (0..40)] # _G. C. Greubel_, Aug 07 2019

%o (GAP) a:=[1,4,5];; for n in [4..30] do a[n]:=a[n-1]+3*a[n-2]-3*a[n-3]; od; a; # _G. C. Greubel_, Aug 07 2019

%Y Cf. A079360, A079363, A028242, A048473 (bisection).

%K easy,nonn

%O 1,2

%A _Cino Hilliard_, Feb 15 2003

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 10:26 EDT 2024. Contains 371905 sequences. (Running on oeis4.)