Determine all unrestricted partitions of an integer. This function is equivalent to the function parts in the partitions package.

partitions(n)

Arguments

n

an integer

Value

a matrix whose rows are the n-tuples

Examples

partitions(5)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 5 0 0 0 0 #> [2,] 4 1 0 0 0 #> [3,] 3 2 0 0 0 #> [4,] 3 1 1 0 0 #> [5,] 2 2 1 0 0 #> [6,] 2 1 1 1 0 #> [7,] 1 1 1 1 1
str(partitions(5))
#> int [1:7, 1:5] 5 4 3 3 2 2 1 0 1 2 ...