Composition Count into Positive Parts
Count ordered compositions of n into exactly k positive parts, with one empty composition of zero and zero for impossible counts; indices are capped at 2,000.
Description
A composition divides an integer into ordered positive parts.
A composition divides an integer into ordered positive parts. Different part orders count separately, distinguishing compositions from integer partitions.1
The tool returns value. The indexing and output conventions below determine how to read these values.
When to use Composition Count into Positive Parts
Use this for the following task: Count ordered compositions of n into exactly k positive parts, with one empty composition of zero and zero for impossible counts; indices are capped at 2,000. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Composition Count into Positive Parts and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter n, k according to the field table, then run the tool.
- Read value. Preserve exact decimal strings and the stated indexing or coefficient order.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| n | Total to compose (resource limit 2000) | integer; minimum 0; maximum 2000 | Required |
| k | Positive part count (resource limit 2000) | integer; minimum 0; maximum 2000 | Required |
Handle zero and impossible part counts explicitly, then use the exact binomial product formula. Return a decimal string.
count = C(n−1,k−1) for 1≤k≤n; count(0,0)=1 The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| value | Composition count | string (integer/arbitrary) |
{
"input": {
"n": 7,
"k": 3
},
"output": {
"value": "15"
}
} Limitations and assumptions
Both indexes are at most 2000. Parts must be positive; allowing zero parts would require a different formula.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Integer Partition Number when you need its operation: Count unordered partitions of n into positive integer parts exactly, including the empty partition of zero; n is capped at 1,000 for bounded computation. Choose Unsigned Lah Number for the complementary operation: Count partitions of n labeled elements into k nonempty linearly ordered blocks using unsigned Lah numbers, including L(0,0)=1; indices are capped at 500.
Background reference: Digital Library of Mathematical Functions, §26.11.
References
-
Digital Library of Mathematical Functions, §26.11 — National Institute of Standards and Technology
Similar or alternative tools
- Integer Partition Number
Count unordered partitions of n into positive integer parts exactly, including the empty partition of zero; n is capped at 1,000 for bounded computation.
- Unsigned Lah Number
Count partitions of n labeled elements into k nonempty linearly ordered blocks using unsigned Lah numbers, including L(0,0)=1; indices are capped at 500.