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 entered5 items, 5 boxes5\ \text{items},\ 5\ \text{boxes}

(5−15−1)=1\displaystyle \binom{5 - 1}{5 - 1} = 1
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 55 boxes first. That leaves 5−5=05 - 5 = 0 items to share out with no restriction.

  2. Stars and bars

    The remaining 00 items go into k=5k = 5 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}

    (0+5−15−1)=(44)=4!4! (4−4)!=4!4! 0!=4×3×2×14×3×2×1=1\begin{aligned} \binom{0 + 5 - 1}{5 - 1} &= \binom{4}{4} \\ &= \frac{4!}{4!\,(4-4)!} \\ &= \frac{4!}{4!\,0!} \\ &= \frac{4 \times 3 \times 2 \times 1}{4 \times 3 \times 2 \times 1} \\ &= 1 \end{aligned}
  3. Result

    So there are 11 ways to share 55 identical items among 55 boxes with at least one in each.

Worked examples