Use this free integer partition calculator to find all the ways a positive integer can be written as a sum of positive integers. The calculator also gives the partition function \(p(n)\), which counts the number of distinct integer partitions.
Enter an integer from 1 to 25. The calculator will generate every integer partition and show the total number of partitions.
Maximum input: 25. Generating every partition becomes increasingly large as the input grows.
An integer partition is a way of writing a positive integer as a sum of positive integers, where the order of the terms does not matter.
For example, the partitions of 5 are:
Therefore:
The expressions \(4+1\) and \(1+4\) represent the same integer partition because their order is irrelevant.
The partition function, written as \(p(n)\), counts the number of distinct integer partitions of \(n\).
Some initial values are:
As \(n\) increases, the number of partitions grows rapidly. For example:
| n | p(n) |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 5 |
| 5 | 7 |
| 6 | 11 |
| 7 | 15 |
| 8 | 22 |
| 9 | 30 |
| 10 | 42 |
| 15 | 176 |
| 20 | 627 |
| 25 | 1958 |
The calculator uses a recursive partition-generation algorithm. At each stage, it chooses the next part of the partition while ensuring that the next part is no larger than the previous part.
This prevents different arrangements of the same numbers from being counted multiple times.
For example, after generating \(4+1\), the calculator does not separately generate \(1+4\), because both represent the same partition.
The algorithm uses memoization to reuse intermediate results. This makes the calculation considerably more efficient than independently generating every possible combination.
Integer partitions and compositions both represent an integer as a sum, but they treat order differently.
In a partition, order does not matter.
In a composition, order matters. Therefore \(4+1\) and \(1+4\) are different compositions.
Therefore: \[ p(3)=3 \]
Therefore: \[ p(4)=5 \]
An integer partition is a way of writing a positive integer as a sum of positive integers where the order of the terms does not matter.
The partition function \(p(n)\) gives the number of distinct integer partitions of \(n\).
The number 5 has 7 integer partitions: \(5\), \(4+1\), \(3+2\), \(3+1+1\), \(2+2+1\), \(2+1+1+1\), and \(1+1+1+1+1\).
No. The order does not matter. For example, \(4+1\) and \(1+4\) are considered the same partition.
The main difference is order. In an integer partition, order does not matter. In a composition, different orders are counted separately.
There are 42 integer partitions of 10, so \[ p(10)=42. \]
The number of integer partitions increases quickly as the input grows. Because this calculator displays every partition, larger inputs can produce a very large result. The current limit keeps the tool practical and responsive.