login
a(0)=1, a(1)=2 continued recursively a(n) = (n-1)*a(n-1) - a(n-2) if n is even and a(n) = a(n-1) - (n-2)*a(n-2) if n is odd.
1

%I #15 Mar 25 2020 18:17:19

%S 1,2,1,-1,-4,-1,-1,4,29,1,-20,-29,-299,20,559,299,3926,-559,-13429,

%T -3926,-61165,13429,343174,61165,1063621,-343174,-9642971,-1063621,

%U -19074796,9642971,298720955,19074796,292597721,-298720955,-10150389236,-292597721,-90530999,10150389236,375654932731

%N a(0)=1, a(1)=2 continued recursively a(n) = (n-1)*a(n-1) - a(n-2) if n is even and a(n) = a(n-1) - (n-2)*a(n-2) if n is odd.

%p A122578 := proc(n) option remember; if n <=1 then op(n+1,[1,2]); elif type(n,'even') then (n-1)*procname(n-1)-procname(n-2) ; else procname(n-1)-(n-2)*procname(n-2) ; end if; end proc: # _R. J. Mathar_, Sep 09 2011

%t a[0] = 1; a[1] = 2; a[n_] := a[n] = If[Mod[n, 2] == 0, (n - 1)*a[n - 1] - a[n - 2], a[n - 1] - (n -2)*a[n - 2]] Table[a[n], {n, 0, 50}]

%t nxt[{n_,a_,b_}]:={n+1,b,If[OddQ[n],n*b-a,b-(n-1)a]}; NestList[nxt,{1,1,2},40][[All,2]] (* _Harvey P. Dale_, Mar 25 2020 *)

%K sign,easy

%O 0,2

%A _Roger L. Bagula_, Sep 17 2006