Integer Composition Calculator

Ordered sums of n

CalculatorsFreeNo Signup
4.6(743 reviews)
All Tools

Loading tool...

About Integer Composition Calculator

An integer composition calculator counting ordered representations of n as sums of positive integers. Unlike partitions (unordered), compositions respect order: 1+2 ≠ 2+1. There are exactly 2^(n-1) compositions of n. Shows all compositions for small n. Client-side.

Integer Composition Calculator Features

  • Composition count
  • List all
  • With k parts
  • Formula
  • Comparison
Compositions of n: ordered ways to write n as a sum of positive integers. 3 has 4 compositions: 3, 2+1, 1+2, 1+1+1. Count: 2^(n-1). With exactly k parts: C(n-1,k-1). Unlike partitions, order matters!

How to Use

Enter n:

  • Count: 2^(n-1)
  • List: All compositions
  • k parts: Restricted count

Why 2^(n-1)?

Place n objects in a row. Between adjacent objects are n-1 gaps. Each gap is either a 'cut' (new part) or not. That's 2 choices per gap = 2^(n-1) total. The bijection: cuts determine parts.

vs Partitions

Partitions: unordered (2+1 = 1+2). Compositions: ordered (2+1 ≠ 1+2). Partitions of 5: 7. Compositions of 5: 16 = 2^4. Compositions are always more numerous because order creates distinctions.

Step-by-Step Instructions

  1. 1Enter n.
  2. 2Count: 2^(n-1).
  3. 3List all.
  4. 4Filter by k parts.
  5. 5Compare to partitions.

Integer Composition Calculator — Frequently Asked Questions

How do compositions with k parts relate to binomial coefficients?+

The number of compositions of n with exactly k parts is C(n-1,k-1). This is 'stars and bars': place k-1 dividers in n-1 gaps. Sum over k: Σ C(n-1,k-1) = 2^(n-1), confirming the total.

What about compositions into specific parts?+

Compositions of n using only parts from set S have generating function (Σ_{s∈S} x^s)^k for k parts. For S={1,2}: Fibonacci numbers! For S={1,2,3}: tribonacci. The restricted compositions connect to recurrence sequences.

What are weak compositions?+

Weak compositions allow parts to be 0. Weak compositions of n with k parts: C(n+k-1,k-1). These count ways to distribute n identical objects into k distinct bins (including empty bins).

Share this tool: