Home

nmultichoosek

nmultichoosek is a combinatorial function that counts the number of ways to choose k elements from an n-element set when repetition is allowed and the order of selection is irrelevant. Equivalently, it counts the number of multisets of size k drawn from an n-element universe.

For nonnegative integers n and k, nmultichoosek(n, k) equals the multiset coefficient binomial(n + k - 1, k)

In mathematical practice, nmultichoosek can be interpreted as the coefficient of x^k in the expansion of (1

Examples: nmultichoosek(5, 3) = binomial(7, 3) = 35, and nmultichoosek(4, 2) = binomial(5, 2) = 10. Applications include counting multisets

=
(n
+
k
-
1)!
/
(k!
(n
-
1)!).
The
value
for
k
=
0
is
1
(the
empty
multiset),
while
if
n
=
0
and
k
>
0
the
value
is
0.
This
function
is
sometimes
described
as
the
number
of
combinations
with
repetition
and
is
closely
related
to
the
stars
and
bars
technique.
+
x
+
x^2
+
...)^n,
reflecting
the
ways
to
distribute
k
indistinguishable
items
into
n
distinct
bins.
It
is
also
referred
to
as
the
multiset
coefficient
(n
choose
k
with
repetition)
and
is
denoted
in
various
texts
by
different
notations;
some
libraries
implement
it
as
NMultichooseK
or
nmultichoosek
with
the
parameters
in
the
order
(n,
k).
in
probability,
combinatorial
enumeration,
and
problems
involving
selection
with
repetition.