## `combinat::composition` -- k-composition of an integer

#### Introduction

`combinat::composition` computes a list of all distinct ordered k-tupels (k_1, ..., k_n) such that n_1 + ... + n_k = n and n_i >= 1, i=1..k.

#### Call(s)

`combinat::composition(n,k)`

#### Parameters

`n, k` | - | integer

#### Returns

A list of type `DOM_LIST` containing every computed k-tupel also as a list of type `DOM_LIST`. If there exist no k-tupel the empty list is returned.

#### Details

- `combinat::composition``(n, k)` returns an empty list if n<1 or k<1 or n<k.

#### Example 1

How can one write 5 as a sum of two other positive integers?

    >> combinat::composition(5,2)

                         [[1, 4], [2, 3], [3, 2], [4, 1]]

#### Example 2

There is no way to write 2 as the sum of 5 positive integers.

    >> combinat::composition(2,5)

                                        []

#### Example 3

`combinat::composition` does not handle symbolic expressions.

    >> combinat::composition(xx,2)

          Error: arguments must be integers [combinat::composition]

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000