public static IEnumerable<IntegerPartition> GetPartitions( int n )
Public Shared Function GetPartitions ( n As Integer ) As IEnumerable(Of IntegerPartition)
public: static IEnumerable<IntegerPartition^>^ GetPartitions( int n )
static member GetPartitions : n : int -> IEnumerable<IntegerPartition>
|ArgumentOutOfRangeException||n is not positive.|
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 partitions 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.