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+3−13−1)=66\displaystyle \binom{10 + 3 - 1}{3 - 1} = 66
Show the work
  1. Stars and bars

    Draw the nn identical items as stars in a row and use k−1k - 1 bars to part them into kk boxes. Each arrangement is a choice of where the k−1k - 1 bars go among n+k−1n + k - 1 places. Here n=10n = 10 and k=3k = 3.

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

    (10+3−13−1)=(122)=12!2! (12−2)!=12!2! 10!=12×112×1=66\begin{aligned} \binom{10 + 3 - 1}{3 - 1} &= \binom{12}{2} \\ &= \frac{12!}{2!\,(12-2)!} \\ &= \frac{12!}{2!\,10!} \\ &= \frac{12 \times 11}{2 \times 1} \\ &= 66 \end{aligned}
  2. Result

    So there are 6666 ways to share 1010 identical items among 33 boxes.

Worked examples