Click or drag to resize
AdvancedIntegerMathPartitions Method
Enumerates all partitions of the given integer

Namespace:  Meta.Numerics.Functions
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: 3.1.0.0 (3.1.0.0)
Syntax
public static IEnumerable<int[]> Partitions(
	int n
)

Parameters

n
Type: SystemInt32
The integer to partition, which must be positive.

Return Value

Type: IEnumerableInt32
An enumeration of all partitions of the given integer.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionn is not positive.
Remarks

Integer partitions are ways to write an integer as a sum of smaller integers. For example, the integer 4 has 5 partitions: 4, 3 + 1, 2 + 2, 2 + 1 + 1, and 1 + 1 + 1 + 1.

Integer partitions appear in combinatoric problems and solutions to problems that may be mapped into combinatoric problems. For example, the terms which appear in Faà di Bruno's formula correspond to integer partitions.

The number of partitions grows very rapidly with n. Since enumerating through partitions does not require us to count them, no overflows will occur even for large values of n. However, completing the enumeration of such a large number of paritions will take a long time, even though our algorithm produces each partition very quickly. For example, there are about two hundred million partitions of the integer 100.

See Also