Multiset

Author

Eric W. Weisstein
February 24, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Combinatorics/Multiset.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Multiset.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

Multisets[l_List,k_]:=Union[Sort/@Flatten[Outer[List,Sequence@@Table[l,{k}]],k-1]]
Multisets[n_,k_]:=Multisets[Range[n],k]

Enumeration

Multisets[{a,b},2]

Multisets[{a,b},3]

Table[Length[Multisets[n,k]],{n,5},{k,5}] //TableForm

Table[Binomial[n+k-1,k],{n,5},{k,5}] //TableForm

Table[Multinomial[n-1,k],{n,5},{k,5}] //TableForm

FullSimplify[FunctionExpand[Multinomial[n-1,k]]]