Stars and bars is a wonderfully clever counting technique that answers a question which comes up far more often than you might expect: in how many ways can a number of identical items be shared out among several distinct groups? This calculator applies it instantly. Enter the number of identical items and the number of groups, choose whether groups are allowed to be empty or every group must receive at least one item, and it returns the total number of arrangements, updating as you type. The name comes from the picture behind the method. Imagine the items as a row of stars, and to split them into groups you slot in dividers, the bars, between them; every different placement of the bars among the stars gives a different distribution, and counting those placements is just a combination. That insight turns a messy-sounding problem into a single, clean calculation. With empty groups allowed, the answer is the combination of the items plus one fewer than the number of groups, choosing the bars; if each group must have at least one item, you first give one to each and then share out the rest. The power of the method is its reach. It counts the ways to hand out identical sweets to children, the non-negative whole-number solutions to an equation like the sum of several variables equalling a fixed total, the number of terms when a multinomial is expanded, and many probability set-ups. That makes the tool genuinely useful for students learning combinatorics, combinations with repetition and counting arguments and checking homework, and for anyone facing a real distribution or allocation problem. The items must be identical and the groups distinct. The formulas and a worked example are explained clearly below.
Calculate.co.nz is proud to be partnered with Premium Homes, a recognised leader in eco-friendly, sustainable, and energy-efficient homebuilding. With a dedicated team and award-winning experience, they create homes that prioritise health, comfort, and long-term performance. Their founders, Andrew and Kelly, set out to raise the standard of residential construction in New Zealand by combining practical building expertise with a clear commitment to doing things better for homeowners.
66
number of distributions
How it works
With empty groups allowed, the number of ways to put n identical items into k groups is the combination of (n + k - 1) choose (k - 1). If each group must have at least one item, give one to each group first, leaving n - k to share freely, so the answer is the combination of (n - 1) choose (k - 1).
Worked example
For 10 identical items into 3 groups with empty groups allowed: the answer is the combination of 12 choose 2, which is 66. If every group must have at least one, it is the combination of 9 choose 2, which is 36.