login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Denominators of continued fraction for left factorial.
2

%I #7 Sep 16 2022 15:25:48

%S 1,-1,0,-1,-2,1,1,0,1,-1,-4,3,14,-11,-63,52,353,-301,-2356,2055,18194,

%T -16139,-159335,143196,1559017,-1415821,-16846656,15430835,199185034,

%U -183754199,-2557127951,2373373752,35416852081,-33043478329,-526322279512,493278801183,8352696141782

%N Denominators of continued fraction for left factorial.

%H G. C. Greubel, <a href="/A056890/b056890.txt">Table of n, a(n) for n = 0..900</a>

%F a(0)=1; a(1)=-1; a(2*n)=n*a(2*n-1)+a(2*n-2); a(2*n+1)= - a(2*n)+a(2*n-1)

%p a:= proc(n) option remember;

%p if n<2 then (-1)^n

%p elif (n mod 2)=0 then (n/2)*a(n-1) +a(n-2)

%p else -a(n-1) +a(n-2)

%p fi; end:

%p seq(a(n), n=0..40); # _G. C. Greubel_, Dec 05 2019

%t a[n_]:= a[n]= If[n<2, (-1)^n, If[EvenQ[n], (n/2)*a[n-1] +a[n-2], -a[n-1] +a[n-2]]]; Table[a[n], {n,0,40}] (* _G. C. Greubel_, Dec 05 2019 *)

%o (PARI) a(n) = if(n<2, (-1)^n, if(Mod(n,2)==0, (n/2)*a(n-1) +a(n-2), -a(n-1) +a(n-2) )); \\ _G. C. Greubel_, Dec 05 2019

%o (Sage)

%o @CachedFunction

%o def a(n):

%o if (n<2): return (-1)^n

%o elif (mod(n,2) ==0): return (n/2)*a(n-1) +a(n-2)

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

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

%o (GAP)

%o a:= function(n)

%o if n<2 then return (-1)^n;

%o elif (n mod 2)=0 then return (n/2)*a(n-1) +a(n-2);

%o else return -a(n-1) +a(n-2);

%o fi; end;

%o List([0..20], n-> a(n) ); # _G. C. Greubel_, Dec 05 2019

%Y Cf. A056889.

%K sign,frac,easy

%O 0,5

%A _Aleksandar Petojevic_, Sep 05 2000

%E More terms from _James A. Sellers_, Sep 06 2000 and from Larry Reeves (larryr(AT)acm.org), Sep 07 2000