Partition Number Calculator
Compute the number of integer partitions for n, along with useful variants from combinatorics and number theory.
Definitions: p(n) = all partitions of n, q(n) = partitions into distinct parts.
What is a partition number?
The partition number p(n) counts how many different ways a positive integer n can be written
as a sum of positive integers, where order does not matter. For example, 4 + 1 and 1 + 4
are the same partition.
Partition numbers grow quickly and appear throughout mathematics. They are central in number theory, combinatorics, generating functions, and even in parts of physics and computer science.
Example: partitions of 5
- 5
- 4 + 1
- 3 + 2
- 3 + 1 + 1
- 2 + 2 + 1
- 2 + 1 + 1 + 1
- 1 + 1 + 1 + 1 + 1
So p(5) = 7.
How this calculator works
1) Unrestricted partitions: p(n)
The calculator uses a dynamic programming method equivalent to multiplying generating function factors
(1 + x^k + x^(2k) + ...) for k = 1..n. This is far faster than brute-force listing
for larger values.
2) Distinct-part partitions: q(n)
It also computes partitions where each part can be used at most once. In this case, updates run backward through the DP array so a part is never reused in the same state transition.
3) Exactly k parts
If you enter k, the tool computes the number of partitions of n with exactly k
positive parts. This is useful in constrained counting problems and classroom exercises.
Why partition numbers matter
- Combinatorics: counting structures, compositions, Ferrers diagrams, and Young tableaux.
- Number theory: Ramanujan congruences, modular forms, asymptotic analysis.
- Algorithms: dynamic programming, state-space counting, symbolic computation.
- Education: a great example of how simple definitions can produce rich mathematics.
Reference values you can test
p(10) = 42p(20) = 627p(50) = 204,226p(100) = 792,070,839
Usage notes
For very large n, partition values become huge, so this page uses JavaScript BigInt to avoid
overflow. If you check “Show explicit partitions,” keep n small so the list remains readable.