combinat::composition --
k-composition of an integer
Introductioncombinat::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)
Parametersn, k |
- | integer |
ReturnsA 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.
Detailscombinat::composition(n, k) returns an
empty list if n<1 or k<1 or
n<k.
Example
1How 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
2There is no way to write 2 as the sum of 5 positive integers.
>> combinat::composition(2,5)
[]
Example
3combinat::composition does not handle
symbolic expressions.
>> combinat::composition(xx,2)
Error: arguments must be integers [combinat::composition]