This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A079362 #24 Sep 08 2022 08:45:08 %S A079362 1,4,5,14,17,44,53,134,161,404,485,1214,1457,3644,4373,10934,13121, %T A079362 32804,39365,98414,118097,295244,354293,885734,1062881,2657204, %U A079362 3188645,7971614,9565937,23914844,28697813,71744534,86093441,215233604 %N A079362 Sequence of sums of alternating powers of 3. %H A079362 G. C. Greubel, <a href="/A079362/b079362.txt">Table of n, a(n) for n = 1..1000</a> %H A079362 <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,3,-3). %F A079362 G.f.: x*(1+3*x-2*x^2)/((1-x)*(1-3*x^2)). - _Michael Somos_, Feb 18 2003 %F A079362 For n >= 1, a(2n-1) = (2/3)*3^n - 1, a(2n) = (5/3)*3^n - 1. - _Benoit Cloitre_, Feb 16 2003 %p A079362 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 A079362 LinearRecurrence[{1,3,-3},{1,4,5},40] (* _Harvey P. Dale_, Oct 18 2016 *) %o A079362 (PARI) a(n)=if(n<1,0,1+sum(k=2,n,3^((k\2)-(k%2)))) %o A079362 (PARI) a(n)=if(n<0,0,(5/3-3*n%2)*2^ceil(n/2)-1) %o A079362 (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 A079362 (Sage) %o A079362 @CachedFunction %o A079362 def a(n): %o A079362 if (n==0): return 1 %o A079362 elif (1<=n<=2): return n+3 %o A079362 else: return a(n-1) + 3*a(n-2) - 3*a(n-3) %o A079362 [a(n) for n in (0..40)] # _G. C. Greubel_, Aug 07 2019 %o A079362 (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 A079362 Cf. A079360, A079363, A028242, A048473 (bisection). %K A079362 easy,nonn %O A079362 1,2 %A A079362 _Cino Hilliard_, Feb 15 2003