login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = 1 + (1-3^n)*a(n-1) for n >=1, a(0) = 0.
4

%I #17 Dec 31 2024 14:44:03

%S 0,1,-7,183,-14639,3542639,-2579041191,5637784043527,

%T -36983863325537119,727916397973221576159,-42982007467522787629036631,

%U 7614090694841791737333323035127,-4046432358866721800888421193787892879

%N a(n) = 1 + (1-3^n)*a(n-1) for n >=1, a(0) = 0.

%H G. C. Greubel, <a href="/A176338/b176338.txt">Table of n, a(n) for n = 0..64</a>

%p A176338 := proc(n)

%p if n = 0 then

%p 0;

%p else

%p 1+(1-3^n)*procname(n-1) ;

%p end if;

%p end proc: # _R. J. Mathar_, May 04 2013

%t a[n_, q_]:= a[n, q]= If[n==0, 0, (1-q^n)*a[n-1, q] +1]; Table[a[n, 3], {n,0,15}]

%t nxt[{n_,a_}]:={n+1,a(1-3^(n+1))+1}; NestList[nxt,{0,0},20][[;;,2]] (* _Harvey P. Dale_, Dec 31 2024 *)

%o (PARI) q=3; a(n,q) = if(n==0, 0, 1 -(q^n-1)*a(n-1,q) );

%o vector(16, n, a(n-1,3)) \\ _G. C. Greubel_, Dec 07 2019

%o (Magma)

%o function a(n,q)

%o if n eq 0 then return 0;

%o else return 1 - (q^n-1)*a(n-1,q);

%o end if; return a; end function;

%o [a(n,3): n in [0..15]]; // _G. C. Greubel_, Dec 07 2019

%o (Sage)

%o def a(n, q):

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

%o else: return 1 - (q^n-1)*a(n-1,q)

%o [a(n,3) for n in (0..15)] # _G. C. Greubel_, Dec 07 2019

%o (GAP)

%o a:= function(n,q)

%o if n=0 then return 0;

%o else return 1 - (q^n-1)*a(n-1,q);

%o fi; end; List([0..15], n-> a(n,3) ); # _G. C. Greubel_, Dec 07 2019

%Y Cf. A176337.

%K sign,easy

%O 0,3

%A _Roger L. Bagula_, Apr 15 2010