login
a(n) = (n-2)*a(n-2) - a(n-3), with a(0)=0, a(1)=1, a(2)=2.
2

%I #9 Sep 08 2022 08:45:27

%S 0,1,2,1,3,1,11,2,65,3,518,-38,5177,-936,62162,-17345,871204,-322337,

%T 13956609,-6350933,251541299,-134624336,5037176913,-3078652355,

%U 110952516422,-75846181078,2665939046483,-2007107043372,69390261389636,-56857829217527,1944934425953180

%N a(n) = (n-2)*a(n-2) - a(n-3), with a(0)=0, a(1)=1, a(2)=2.

%H G. C. Greubel, <a href="/A122048/b122048.txt">Table of n, a(n) for n = 0..800</a>

%F a(n) = (n-2)*a(n-2) - a(n-3).

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

%p if n < 3 then n

%p elif n = 3 then 1

%p else (n-2)*a(n-2) - a(n-3)

%p end if

%p end proc:

%p seq(a(n), n = 0..35); # _G. C. Greubel_, Oct 04 2019

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

%o (PARI) my(m=35, v=concat([0,1,2,1], vector(m-4))); for(n=5, m, v[n] = (n-3)*v[n-2] - v[n-3] ); v \\ _G. C. Greubel_, Oct 04 2019

%o (Magma) I:=[0,1,2,1]; [n le 4 select I[n] else (n-3)*Self(n-2) - Self(n-3): n in [1..35]]; // _G. C. Greubel_, Oct 04 2019

%o (Sage)

%o def a(n):

%o if n<3: return n

%o elif n==3: return 1

%o else: return (n-2)*a(n-2) - a(n-3)

%o [a(n) for n in (0..35)] # _G. C. Greubel_, Oct 04 2019

%o (GAP) a:=[0,1,2,1];; for n in [5..35] do a[n]:=(n-3)*a[n-2]-a[n-3]; od; a; # _G. C. Greubel_, Oct 04 2019

%Y Cf. A122021.

%K sign

%O 0,3

%A _Roger L. Bagula_, Sep 13 2006

%E Offset changed by _G. C. Greubel_, Oct 04 2019