login
a(2n) = (n^2-n-1) + a(2n-2), a(2n+1) = (n^2-n-1)*a(2n-1), with a(0)=0 and a(1)=1.
1

%I #17 Mar 03 2021 09:45:53

%S 0,1,-1,-1,0,-1,5,-5,16,-55,35,-1045,64,-30305,105,-1242505,160,

%T -68337775,231,-4851982025,320,-431826400225,429,-47069077624525,560,

%U -6166049168812775,715,-955737621165980125,896,-172988509431042402625

%N a(2n) = (n^2-n-1) + a(2n-2), a(2n+1) = (n^2-n-1)*a(2n-1), with a(0)=0 and a(1)=1.

%C Essentially A077415 and A130031 interleaved, see formulas.

%H G. C. Greubel, <a href="/A154232/b154232.txt">Table of n, a(n) for n = 0..351</a>

%F From _Robert Israel_, Sep 06 2016: (Start)

%F a(2*n) = A077415(n) for n >= 2.

%F a(2*n+1) = cos(Pi*sqrt(5)/2)*Gamma(n+1/2-sqrt(5)/2)*Gamma(n+1/2+sqrt(5)/2)/Pi.

%F a(2*n+1) = (-1)^n*A130031(n). (End)

%p a[0]:= 0: a[1]:= 1:

%p for n from 1 to 49 do

%p a[2*n]:= (n^2-n-1) +a[2*n-2];

%p a[2*n+1]:= (n^2-n-1)*a[2*n-1];

%p od:

%p seq(a[i],i=0..99); # _Robert Israel_, Sep 06 2016

%t (* First program *)

%t b[n_]:= b[n]= If[n==0, 0, n^2 -n -1 + b[n-1]];

%t c[n_]:= c[n]= If[n==0, 1, (n^2 -n -1)*c[n-1]];

%t Flatten[Table[{b[n], c[n]}, {n, 0, 15}]] (* modified by _G. C. Greubel_, Mar 02 2021 *)

%t (* Second program *)

%t a[n_]:= a[n]= If[n<2, n, If[EvenQ[n], ((n^2-2*n-4)/4) + a[n-2], ((n^2-4*n-1)/4)*a[n-2]]];

%t Table[a[n], {n,0,40}] (* _G. C. Greubel_, Mar 02 2021 *)

%o (Sage)

%o def a(n):

%o if (n<2): return n

%o elif (n%2==0): return ((n^2-2*n-4)/4) + a(n-2)

%o else: return ((n^2-4*n-1)/4)*a(n-2)

%o [a(n) for n in (0..40)] # _G. C. Greubel_, Mar 02 2021

%o (Magma)

%o function a(n)

%o if n lt 2 then return n;

%o elif (n mod 2 eq 0) then return ((n^2-2*n-4)/4) + a(n-2);

%o else return ((n^2-4*n-1)/4)*a(n-2);

%o end if; return a;

%o end function;

%o [a(n): n in [0..40]]; // _G. C. Greubel_, Mar 02 2021

%Y Cf. A077415, A130031.

%K sign

%O 0,7

%A _Roger L. Bagula_, Jan 05 2009

%E Edited by _Robert Israel_, Sep 06 2016