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!)
A121956 a(n) = a(n-1) + (n-2)*a(n-2) + a(n-3) starting a(0)=0, a(1)=a(2)=1. 1

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

%S 0,1,1,2,5,12,34,99,315,1042,3661,13354,51006,201561,826987,3498286,

%T 15277665,68578942,316519868,1497639547,7263576113,36035247374,

%U 182804409181,946808180148,5004540429504,26963932982089,148019711470333

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

%H G. C. Greubel, <a href="/A121956/b121956.txt">Table of n, a(n) for n = 0..795</a>

%p with(combinat);

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

%p if n<3 then fibonacci(n)

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

%p fi;

%p end:

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

%t M = {{0,1,0}, {0,0,1}, {1,n,1}}; v[0]= {0,1,1}; v[n_]:= v[n]= M.v[n-1]; Table[v[n][[1]], {n, 0, 30}]

%t a[n_]:= a[n]= If[n<3, Fibonacci[n], a[n-1] + (n-2)*a[n-2] + a[n-3]]; Table[a[n], {n,0,30}] (* _G. C. Greubel_, Oct 06 2019 *)

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

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

%o (Sage)

%o @CachedFunction

%o def a(n):

%o if (n<3): return fibonacci(n)

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

%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 Fibonacci(n);

%o else return a(n-1) + (n-2)*a(n-2) + a(n-3);

%o fi;

%o end;

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

%K nonn

%O 0,4

%A _Roger L. Bagula_, Sep 01 2006

%E Definition replaced by recurrence - the Assoc. Eds. of the OEIS, Mar 27 2010

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

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 25 12:53 EDT 2024. Contains 371969 sequences. (Running on oeis4.)