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

  1. Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
  2. Enter n, k according to the field table, then run the tool.
  3. Read value. Preserve exact decimal strings and the stated indexing or coefficient order.
  4. Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
Input fieldMeaningValue type and boundsRequirement
nTotal to compose (resource limit 2000)integer; minimum 0; maximum 2000Required
kPositive part count (resource limit 2000)integer; minimum 0; maximum 2000Required

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 fieldMeaningValue type
valueComposition countstring (integer/arbitrary)
json
{
  "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

  1. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies