counting compositions of an integer

A compositionMathworldPlanetmathPlanetmath of a nonnegative integer n is a sequenceMathworldPlanetmath (a1,,ak) of positive integers with ai=n. Denote by Cn the number of compositions of n, and denote by Sn the set of those compositions. (Note that this is a very different - and simpler - concept than the number of partitionsMathworldPlanetmathPlanetmath of an integer; here the order ( matters).

For some small values of n, we have

C0 =1
C1 =1
C2 =2  (2),(1,1)
C3 =4  (3),(1,2),(2,1),(1,1,1)

In fact, it is easy to see that Cn=2Cn-1 for n>1: each composition (a1,,ak) of n-1 can be associated with two different compositions of n


We thus get a map φ:Sn-1×{0,1}Sn given by


and this map is clearly injectivePlanetmathPlanetmath. But it is also clearly surjectivePlanetmathPlanetmath, for given (a1,,ak)Sn, if ak=1 then the composition is the image of ((a1,,ak-1),0) while if ak>1, then it is the image of ((a1,,ak-1),1). This proves that (for n>1) Cn=2Cn-1.

We can also figure out how many compositions there are of n with k parts. Think of a box with n sections in it, with dividers between each pair of sections and a chip in each section; there are thus n chips and n-1 dividers. If we leave k-1 of the dividers in place, the result is a composition of n with k parts; there are obviously (n-1k-1) ways to do this, so the number of compositions of n into k parts is simply (n-1k-1). Note that this gives even a simpler proof of the first result, since

Title counting compositions of an integer
Canonical name CountingCompositionsOfAnInteger
Date of creation 2013-03-22 17:37:55
Last modified on 2013-03-22 17:37:55
Owner rm50 (10146)
Last modified by rm50 (10146)
Numerical id 5
Author rm50 (10146)
Entry type Result
Classification msc 05-00
Defines composition