Stars and Bars Calculator

Enter the number of identical items and boxes to count the ways to share them out.

A whole number from 0 to 1000.

A whole number from 1 to 1000.

Each box

Whether a box is allowed to stay empty.

Try

Result

You entered10 items, 3 boxes10\ \text{items},\ 3\ \text{boxes}

(10−13−1)=36\displaystyle \binom{10 - 1}{3 - 1} = 36
Show the work
  1. Give each box one first

    If every box must get at least one item, put one item in each of the 33 boxes first. That leaves 10−3=710 - 3 = 7 items to share out with no restriction.

  2. Stars and bars

    The remaining 77 items go into k=3k = 3 boxes with no restriction, so use stars and bars on them: ((n−k)+k−1k−1)=(n−1k−1)\binom{(n - k) + k - 1}{k - 1} = \binom{n - 1}{k - 1}.

    Using (n+k−1k−1)\binom{n + k - 1}{k - 1}

    (7+3−13−1)=(92)=9!2! (9−2)!=9!2! 7!=9×82×1=36\begin{aligned} \binom{7 + 3 - 1}{3 - 1} &= \binom{9}{2} \\ &= \frac{9!}{2!\,(9-2)!} \\ &= \frac{9!}{2!\,7!} \\ &= \frac{9 \times 8}{2 \times 1} \\ &= 36 \end{aligned}
  3. Result

    So there are 3636 ways to share 1010 identical items among 33 boxes with at least one in each.

Worked examples