Next: printfactors()
Up: Mathematical Macros Help File
Previous: orthopoly()
Contents
Usage:
Keywords:
integers
Usage
partitions(n), where n > 0 is an integer, computes a matrix with n
columns whose rows, possibly padded with 0, are the partitions of n. A
partition of n is a non-increasing set of integers summing to n.
partitions(n,all:T) returns a structure R with n components, such that
R[j] is a matrix with j columns whose rows are the partitions of j
(padded with 0).
The number N of partitions of n grows fairly rapidly:
n N n N n N n N
1 1 7 15 13 101 19 490
2 2 8 22 14 135 20 627
3 3 9 30 15 176 21 792
4 5 10 42 16 231 22 1002
5 7 11 56 17 297 23 1255
6 11 12 77 18 385 24 1575
Examples:
Cmd> partitions(4) # all 5 partitions of 4; rows add to 4
(1,1) 4 0 0 0
(2,1) 3 1 0 0
(3,1) 2 2 0 0
(4,1) 2 1 1 0
(5,1) 1 1 1 1
Cmd> partitions(3,all:T) # partitions of 1, 2 and 3
component: Parts_of_1
(1,1) 1
component: Parts_of_2
(1,1) 2 0
(2,1) 1 1
component: Parts_of_3
(1,1) 3 0 0
(2,1) 2 1 0
(3,1) 1 1 1
Gary Oehlert
2006-01-30