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

Exact distributions

Enter valid values to see the result.

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

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.