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

%I #30 Sep 08 2022 08:45:28

%S 0,1,2,1,3,11,53,317,2216,17717,159400,1593683,17528297,210321847,

%T 2734024611,38274750871,574103734768,9185449434441,156149906360886,

%U 2810660039745077,53401966651421695,1068030147578999459,22428476949252627753,493423682223518065489

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

%H G. C. Greubel, <a href="/A122050/b122050.txt">Table of n, a(n) for n = 0..449</a> [Offset adapted by _Georg Fischer_, Jun 06 2021]

%F a(n) ~ c * (n-1)!, where c = 0.438972920465828798175530475000702431170711231072281289641... - _Vaclav Kotesovec_, Jun 06 2021

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

%p if n < 3 then n elif n = 3 then 1 else (n-1)*a(n-1)-a(n-4) end if

%p end proc:

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

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

%t RecurrenceTable[{a[0]==0,a[1]==1,a[2]==2,a[3]==1,a[n]==(n-1)a[n-1]- a[n-4]}, a,{n,0,30}] (* _Harvey P. Dale_, Jul 16 2016 *)

%t CoefficientList[AsymptoticDSolveValue[{(x^4 + 1)*f[x] - x^2*f'[x] + 3*x^3 - x^2 - x == 0, f[1] == 1}, f[x], {x, 0, 20}], x] (* version >=12, _Vaclav Kotesovec_, Jun 06 2021 *)

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

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

%o (Sage)

%o def a(n):

%o if n<4: return n-1

%o elif n==4: return 1

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

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

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

%Y Cf. A122022.

%K nonn

%O 0,3

%A _Roger L. Bagula_, Sep 13 2006

%E Offset changed to 0 by _Georg Fischer_, Jun 06 2021