OFFSET
1,2
COMMENTS
a(n) is the number of ways to place n indistinguishable balls into n distinguishable boxes with either 1 or 2 boxes remaining empty.
a(n) is also the number of weak compositions of n into n parts that contain either one or two 0's.
a(n)+1 is the number of ways to place n indistinguishable balls into n distinguishable boxes with at most 2 boxes remaining empty (just add the case of no empty boxes in which we place exactly one ball in one box).
LINKS
Index entries for linear recurrences with constant coefficients, signature (5,-10,10,-5,1).
FORMULA
G.f.: x^2*(2 - x + 5*x^2)/(1 - x)^5. - Stefano Spezia, Mar 15 2022
EXAMPLE
a(4)=30 since 4 can be written as 3+1+0+0, 0+3+0+1, etc. (12 such compositions); 2+2+0+0 (6 such compositions); 2+1+1+0 (12 such compositions).
MATHEMATICA
a[n_] := Binomial[n, 2] * (Binomial[n - 1, 2] + 2); Array[a, 50] (* Amiram Eldar, Mar 15 2022 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Mar 14 2022
STATUS
approved