How to use (3 steps)
- Choose Composition or Partition, then pick the constraint you need.
- Enter n (and k/a/b when required), then select count, table, enumeration, or sample.
- Export CSV/TSV or copy a shareable URL for reuse.
Inputs
--
Table
Examples
Key formulas and notes
- Compositions count is 2^(n-1) for n >= 1, and k parts use C(n-1, k-1).
- Nonnegative k-part compositions use stars and bars: C(n+k-1, k-1).
- Partitions ignore order; use the Partition tab to compare counts.
- Enumeration is limited for speed; use samples for larger n.
FAQ
What is the difference between partitions and compositions?
Partitions ignore order while compositions treat different orders as distinct.
Why is composition count 2^(n-1)?
Each of the n-1 gaps is a divider or not, giving 2^(n-1) combinations.
How do I count compositions with exactly k parts?
Select exactly k parts to compute C(n-1, k-1).
What is the nonnegative k-part formula?
It is C(n+k-1, k-1), the stars and bars count.
Can I restrict parts to a range?
Use bounded parts to restrict each part to [a, b].
Why is enumeration limited for large n?
The number of compositions grows quickly, so enumeration is capped.
Can I compute modulo m?
Yes. Switch to modulo mode and enter the modulus.
Do these samples use a fixed seed?
Yes. The same seed reproduces the same list of samples.