login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A121956
a(n) = a(n-1) + (n-2)*a(n-2) + a(n-3) starting a(0)=0, a(1)=a(2)=1.
1
0, 1, 1, 2, 5, 12, 34, 99, 315, 1042, 3661, 13354, 51006, 201561, 826987, 3498286, 15277665, 68578942, 316519868, 1497639547, 7263576113, 36035247374, 182804409181, 946808180148, 5004540429504, 26963932982089, 148019711470333
OFFSET
0,4
LINKS
MAPLE
with(combinat);
a:= proc(n) option remember;
if n<3 then fibonacci(n)
else a(n-1) + (n-2)*a(n-2) + a(n-3)
fi;
end:
seq(a(n), n=0..30); # G. C. Greubel, Oct 06 2019
MATHEMATICA
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}]
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 *)
PROG
(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
(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
(Sage)
@CachedFunction
def a(n):
if (n<3): return fibonacci(n)
else: return a(n-1) + (n-2)*a(n-2) + a(n-3)
[a(n) for n in (0..30)] # G. C. Greubel, Oct 06 2019
(GAP)
a:= function(n)
if n<3 then return Fibonacci(n);
else return a(n-1) + (n-2)*a(n-2) + a(n-3);
fi;
end;
List([0..30], n-> a(n) ); # G. C. Greubel, Oct 06 2019
CROSSREFS
Sequence in context: A196545 A032292 A151408 * A348102 A176638 A131467
KEYWORD
nonn
AUTHOR
Roger L. Bagula, Sep 01 2006
EXTENSIONS
Definition replaced by recurrence - the Assoc. Eds. of the OEIS, Mar 27 2010
Offset changed by G. C. Greubel, Oct 06 2019
STATUS
approved