Counting, Permutations & Combinations

Stars and Bars Calculator

Count distributions of identical objects among labeled boxes.

Counting & Combinatorics

Distribute identical objects into labeled boxes

Stars and bars
  1. 1EnterProvide the known values
  2. 2CalculateResults update automatically
  3. 3VerifyReview the details and units
Try an example

Exact distributions

Enter valid values to see the result.

Your entries are calculated in this browser and are not submitted to 365CALCS.COM.

Feedback

Understand the subject

What does stars and bars count?

Stars and bars represents identical objects as stars and labelled boxes as gaps created by divider bars. The picture converts allocation into arrangement.

Use it to distribute identical units among labelled categories.

The relationship

The counting rule

See the structure

Bars divide identical stars into labelled boxes

Worked example

Check the rule with a small case

Five identical objects in 3 labelled boxes, allowing empty boxes: C(7,2) = 21.

Interpret with care

Choose the right counting model

The objects must be identical and boxes labelled. Requiring every box to be nonempty changes the formula.

Use the Permutation & Combination Generator when a small case needs to be inspected rather than only counted.

Quick guide

How to use this calculator

  1. Enter the number of identical objects and labeled boxes.
  2. Choose whether empty boxes are allowed.
  3. Read the exact number of distributions.

Calculation method

Separate identical objects with bars

Allowing empty boxes gives C(n+k−1,k−1). Requiring every box to be non-empty gives C(n−1,k−1), provided n is at least k.

Worked example

Distribute five objects among three boxes

When empty boxes are allowed, five stars and two bars can be arranged in 21 ways.

C(5+3−1,3−1) = C(7,2) = 21

Supported inputs

Precision and limits

Discrete domain

Inputs are whole counts. Negative, fractional, grouped, and scientific-notation inputs are rejected.

Exact integers

Results use arbitrary-precision integers and are never rounded. Inputs and output size are bounded to keep the page responsive.