Maxima Function
integer_partitions (n)
integer_partitions(n,len)
Returns integer partitions of n, that is, lists of integers which sum to n.
integer_partitions(n)
returns the set of
all partitions of the integer n.
Each partition is a list sorted from greatest to least.
integer_partitions(n, len)
returns all partitions that have length len or less; in this
case, zeros are appended to each partition with fewer than len
terms to make each partition have exactly len terms.
Each partition is a list sorted from greatest to least.
A list [a_1, ..., a_m] is a partition of a nonnegative integer n when (1) each a_i is a nonzero integer, and (2) a_1 + ... + a_m = n. Thus 0 has no partitions.
Examples:
(%i1) integer_partitions (3); (%o1) {[1, 1, 1], [2, 1], [3]} (%i2) s: integer_partitions (25)$ (%i3) cardinality (s); (%o3) 1958 (%i4) map (lambda ([x], apply ("+", x)), s); (%o4) {25} (%i5) integer_partitions (5, 3); (%o5) {[2, 2, 1], [3, 1, 1], [3, 2, 0], [4, 1, 0], [5, 0, 0]} (%i6) integer_partitions (5, 2); (%o6) {[3, 2], [4, 1], [5, 0]}
To find all partitions that satisfy a condition, use the function subset
;
here is an example that finds all partitions of 10 that consist of prime numbers.