GenerateRandomSearch

Integer Composition Generator

How many ways can you write 5 as a sum of positive whole numbers, if order matters? The answer is exactly 16, and it is 2 to the power of 4 — because between the five units there are four gaps, and each is either a break or not. That argument makes the count obvious once you see it, and it is a good example of a bijection doing the work a formula would otherwise have to.

What this generator does

Lists every ordered sum of positive whole numbers reaching the total, breaks the count down by how many parts each uses, and compares the total against 2 to the power of one less than the number.

How to use this tool

  1. Choose the number to split.
  2. Predict the count before generating.
  3. Compare the enumeration against two to the power of one less.
  4. Show the full list to see them all.

Understanding the controls

The number to split
Between 2 and 9. Nine has 256 compositions, which is the practical limit for listing them.
Seed
Chooses which composition is shown as the example.
Show the full list
Lists every composition rather than just the count and one example.

Common use cases

  • Counting exercises where the gap argument makes the formula obvious
  • Showing the difference between compositions and partitions
  • Test data for anything consuming ordered decompositions
  • Teaching bijective proofs concretely
  • Picking a specific composition from a seed

How this generator works

Enumeration builds each composition by choosing the first part and recursing on the remainder, which produces each ordered sum exactly once. The check requires the count to equal 2 to the power of one less than the total — the gap argument — and every composition to sum correctly with no repeats.

Randomness and fairness

Only which composition is shown as the example is random; the enumeration and the count are fixed for a given total. Seeded runs pick the same example and are therefore explicitly not cryptographically secure.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Nine is the ceiling, since the count doubles with every increment.
  • Compositions only — partitions, where order does not matter, are a much harder counting problem with no simple formula.
  • Parts must be positive, so zero parts never appear.
  • Compositions are listed in enumeration order rather than sorted.
  • Nothing is retained after the visit; seed it to return to one composition.

Privacy and your data

Compositions are enumerated in your browser. Nothing about them or your seed is transmitted.