IntegerPartitions

Integer partition (SymPy, WMA)


IntegerPartitions[n]

lists all possible ways to partition integer n into smaller integers.

IntegerPartitions[n, k]

lists all partitions into at most k integers.

IntegerPartitions[n, {k}]

lists all partitions with exactly k integers.

IntegerPartitions[n, {$k_{min}$, $k_{max}$}]

lists partitions between $k_{min}$ and $k_{max}$ integers.

IntegerPartitions[n, kspec, {$s_1$, $s_2$, ...}]

lists partitions involving only the $s_i$.

All partitions of positive integers that add to 5:

Limit the above to just the first 3 elements:

Partitions of 5 with at most 3 integers:

Partitions of 5 with exactly 3 integers; this is a subset of “at most 3” above:

Partitions of 5 that involve only integers 1, and 2:

Partitions of 4 with exactly 2 elements and involve only integers -1, 0, 1, 4, and 5:

IntegerPart
JacobiSymbol