Loading…

Stars and Bars Theorem Calculator

Math Probability • Combinatorics and Counting Techniques

View all topics

Stars and Bars Calculator – Distributions of Indistinguishable Objects (Free)

Count solutions to distributing \(n\) identical items into \(k\) bins using the stars and bars theorem. Non-negative: \(x_1+\cdots+x_k=n\). Positive: \(x_i\ge 1\).

Tip: Fill example \(n=10\), \(k=4\) (non-negative) → \(\binom{13}{3}=286\). Press Play to animate the stars/bars layout.

Inputs
Inputs accept 1e3, pi, e, sqrt(2). Use * for multiplication.
Animation & view
Drag to pan the layout; wheel/trackpad to zoom (useful when \(n\) and \(k\) are larger).
Ready
Interactive stars & bars view — layout + bin counts

The diagram is schematic. In positive mode, the visualized stars represent \(y_i=x_i-1\) (so total stars \(=n-k\)).

Rate this calculator

0.0 /5 (0 ratings)
Be the first to rate.
Your rating
You can update your rating any time.

Frequently Asked Questions

What does stars and bars count?

It counts the number of integer solutions to x1+...+xk=n when objects are identical and bins are distinct, using a stars-and-bars separator model.

Why is the non-negative formula C(n+k-1, k-1)?

You place k-1 bars among n+k-1 total slots (n stars plus k-1 bars). Each bar placement uniquely determines the k bin counts.

How do you handle positive solutions xi ≥ 1?

Let yi=xi-1 so yi ≥ 0 and y1+...+yk=n-k. Then apply stars and bars to get C(n-1, k-1) (requires n ≥ k).

What about upper limits like xi ≤ ui?

Upper bounds usually require inclusion–exclusion or generating functions, because unrestricted stars-and-bars overcounts assignments that exceed limits.