public static IEnumerable<int> Partitions( int n )
Public Shared Function Partitions ( n As Integer ) As IEnumerable(Of Integer())
public: static IEnumerable<array<int>^>^ Partitions( int n )
static member Partitions : n : int -> IEnumerable<int>
|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 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.