Learn R Programming

kStatistics (version 1.0)

intPart: Integer partitions

Description

Generates all possible (unique) ways to represent a positive integer n as sum of positive integers.

Usage

intPart(n)

Arguments

n

integer

Value

list

all partitions of n

Details

A partition of an integer n is a sequence of weakly increasing integers such that their sum returns n. The function generates all the partitions of a given integer in sorted order and numbers within a partition in sorted order too.

References

Nijenhuis A. and Wilf. H., Combinatorial Algorithms for Computers and Calculators. Academic Press, Orlando FL, II edition, 1978.

See Also

mkmSet, umSet, mCoeff, nStirling2, countP, df

Examples

Run this code
# NOT RUN {
intPart(3) 
# returns the partitions [1,1,1],[1,2],[3] 

intPart(4) 
# returns the partitions [1,1,1,1],[1,3],[2,2],[4]
# }

Run the code above in your browser using DataLab