MathorynMathematical Formula Database

Combinatorics

Stars and Bars (Positive Solutions)

The number of ways to write nn as an ordered sum of kk positive integers equals (n−1k−1)\binom{n-1}{k-1}: place k−1k-1 bars in the n−1n-1 gaps between nn stars. It is used to count distributions of identical objects where everyone gets at least one.

#{x1+⋯+xk=n, xi≥1}=(n−1k−1)\#\{x_1+\cdots+x_k=n,\ x_i\ge1\}=\binom{n-1}{k-1}
LaTeX\#\{x_1+\cdots+x_k=n,\ x_i\ge1\}=\binom{n-1}{k-1}

Variables

nn
total to distribute
kk
number of parts (recipients)
xix_i
positive integer parts

Example

In how many ways can 1010 identical sweets be shared by 44 children, each getting at least one?

  1. n=10, k=4n=10,\ k=4.
  2. (93)=9⋅8⋅76\binom93=\frac{9\cdot8\cdot7}{6}.

Answer: 8484 ways.

Related formulas