login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A122022 a(n) = a(n-1) - (n-1)*a(n-4), with a(0) = 0, a(1) = 1, a(2) = 2, a(3) = 1. 4

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

%S 0,1,2,1,1,-3,-13,-19,-26,-2,115,305,591,615,-880,-5150,-14015,-23855,

%T -8895,83805,350090,827190,1013985,-829725,-8881795,-28734355,

%U -54083980,-32511130,207297335,1011859275,2580294695,3555628595,-2870588790,-35250085590

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

%H Harvey P. Dale, <a href="/A122022/b122022.txt">Table of n, a(n) for n = 0..999</a> [Offset adapted by _Georg Fischer_, Jun 06 2021]

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

%p if n<3 then n

%p elif n=3 then 1

%p else a(n-1) - (n-1)*a(n-4)

%p fi;

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

%t a[0]=0; a[1]=1; a[2]=2; a[3]=1; a[n_]:= a[n]= a[n-1] - (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]==a[n-1]- (n-1) a[n-4]},a,{n,0,30}] (* _Harvey P. Dale_, Nov 28 2014 *)

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

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

%o (Sage)

%o @CachedFunction

%o def a(n):

%o if (n<3): return n

%o elif (n==3): return 1

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

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

%o (GAP)

%o a:= function(n)

%o if n<3 then return n;

%o elif n=3 then return 1;

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

%o fi;

%o end;

%o List([1..30], n-> a(n) ); # _G. C. Greubel_, Oct 06 2019

%Y Cf. A000898, A062267, A121966, A122050.

%K sign

%O 0,3

%A _Roger L. Bagula_, Sep 12 2006

%E Edited by _N. J. A. Sloane_, Sep 12 2006

%E Offset corrected by _Georg Fischer_, Jun 06 2021

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 20:08 EDT 2024. Contains 371963 sequences. (Running on oeis4.)