Maths & numbers

Integer composition count calculator

Count ordered ways to split a positive total into a fixed number of positive parts.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

For total 5 split into two parts, 1+4 and 4+1 are separate compositions.

THE FORMULAC(total − 1, parts − 1)

A worked example

Split seven unit marks at two of the six interior gaps to get 15 compositions.

Good to know

A composition has no zero parts.

Choose cuts between consecutive unit marks

To split a total of seven into three positive ordered parts, place seven unit marks in a row. There are six internal gaps. Selecting two of those gaps as cuts creates three nonempty runs. The count is C(6,2) = 15, matching the default result.

For example, cuts after units 2 and 3 produce parts 2, 1 and 4. Moving the first cut to gap 1 while keeping the second at gap 3 gives 1, 2 and 4. Those are different compositions because the sequence of part sizes matters.

Two cuts divide seven units into an ordered run of two, one and four214C(6,2) = 15 compositions
There are six interior gaps between seven unit marks. Choosing any two distinct gaps creates three positive ordered parts.

Check positivity and the number of available cuts

Each part must contain at least one unit, so the number of parts cannot exceed the total. The binomial count is zero when more than n − 1 cuts are requested. With one part there is only the original total, and with seven parts totaling seven every part must be one.

The Stars and bars distribution calculator allows zero entries in labelled boxes. Positive compositions instead select interior gaps without repetition, ensuring every part has positive size. The Integer partition count calculator ignores ordering and allows the part count to vary. Decide which of these conditions matches your problem before using one of the counts as a denominator or probability model.

A few questions, answered

Are 2 + 1 + 4 and 4 + 1 + 2 distinct?

Yes. A composition is ordered, so swapping parts changes the result unless the sequence stays identical.

Can the total be zero?

This implementation requires a positive total and a positive number of positive parts.

Find your calculator

Start typing to explore the library.