Partition Function Calculator
Compute the partition function p(n), the number of ways to write n as a sum of positive integers. Enumerate every partition for small n with animated Young (Ferrers) diagrams, compare distinct-parts q(n) vs. odd-parts o(n) (Euler's theorem), plot the growth curve, and benchmark against the Hardy-Ramanujan asymptotic approximation.
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
About Partition Function Calculator
Welcome to the Partition Function Calculator, a full-featured explorer for one of combinatorics' most fascinating objects. Enter any non-negative integer \(n\) and this tool computes \(p(n)\) — the number of ways to write \(n\) as a sum of positive integers where order does not matter — together with the number of partitions into distinct parts \(q(n)\), the number of partitions into odd parts \(o(n)\), the Hardy-Ramanujan asymptotic estimate, every matched Ramanujan congruence, and (for small \(n\)) every single partition rendered as an animated Young diagram.
What is the Partition Function p(n)?
The partition function \(p(n)\) counts the number of ways to write \(n\) as a sum of positive integers, disregarding order. Two sums that differ only in the order of their summands are considered the same partition. For example, the partitions of 4 are:
- 4
- 3 + 1
- 2 + 2
- 2 + 1 + 1
- 1 + 1 + 1 + 1
That gives \(p(4) = 5\). By convention \(p(0) = 1\), counting the "empty partition". A few more values: \(p(1) = 1,\ p(5) = 7,\ p(10) = 42,\ p(50) = 204{,}226,\ p(100) = 190{,}569{,}292.\)
Generating Function
Leonhard Euler discovered that the generating function for \(p(n)\) has a beautifully compact product form:
Every factor \(1/(1 - x^k) = 1 + x^k + x^{2k} + \ldots\) contributes the choice of how many times the part \(k\) appears in the partition. Multiplying the factors together generates every partition exactly once.
Young (Ferrers) Diagrams
A Young diagram (also called a Ferrers diagram) represents a partition visually as a left-justified array of boxes. Each row corresponds to one part, and the rows are listed from largest to smallest. For example, the partition \(4 + 2 + 1\) of 7 becomes:
Young diagrams let you "see" partition identities. Reflecting a diagram across its main diagonal turns rows into columns, which corresponds to the conjugate partition. This calculator renders a Young diagram for every partition of \(n\) whenever \(n \le 15\).
Euler's Partition Theorem
One of Euler's most elegant results states:
For example, the partitions of 7 into distinct parts are \(\{7\}, \{6+1\}, \{5+2\}, \{4+3\}, \{4+2+1\}\) — five of them. The partitions of 7 into odd parts are \(\{7\}, \{5+1+1\}, \{3+3+1\}, \{3+1+1+1+1\}, \{1+1+1+1+1+1+1\}\) — also five. The calculator's summary panel reports both \(q(n)\) and \(o(n)\) so you can verify this identity for your chosen \(n\).
The Hardy-Ramanujan Asymptotic
In 1918, G.H. Hardy and Srinivasa Ramanujan proved the first formula that captured the true growth rate of \(p(n)\) for large \(n\):
The result emerged from the Hardy-Ramanujan circle method, which integrates the generating function around singularities on the unit circle. Hans Rademacher refined it in 1937 into an exact convergent series — one of the most celebrated formulas in analytic number theory.
Ramanujan's Partition Congruences
While studying the table of partition values, Ramanujan noticed three astonishing divisibility patterns:
For instance, \(p(4)=5,\ p(9)=30,\ p(14)=135,\ p(19)=490,\ p(24)=1575\) are all divisible by 5. The calculator automatically flags whenever your chosen \(n\) sits in one of these classes.
How to Use This Calculator
- Enter a non-negative integer up to 500 in the input box, or click one of the famous quick examples (0, 4, 10, 42, 100, 200).
- Click "Calculate Partitions". The tool computes \(p(n)\), \(q(n)\), \(o(n)\), and the Hardy-Ramanujan estimate.
- Review the hero panel showing \(p(n)\) as a large headline number, then scan the summary grid for distinct-parts, odd-parts, the asymptotic estimate, and percentage error.
- Inspect Young diagrams — if \(n \le 15\), every single partition is drawn as an animated Young diagram in a responsive grid.
- Explore the growth chart — plots \(p(k)\), \(q(k)\), and the Hardy-Ramanujan curve for \(k = 0, 1, \ldots, n\). Toggle between linear and log scale to see the asymptotic shape.
- Read the growth table — a line-by-line view of \(p(k), q(k), o(k)\) for small \(k\). Use it to spot the first occurrence of each Ramanujan congruence.
Worked Example: Partitions of 5
Let us walk through \(n = 5\). All partitions are:
- \(5\)
- \(4 + 1\)
- \(3 + 2\)
- \(3 + 1 + 1\)
- \(2 + 2 + 1\)
- \(2 + 1 + 1 + 1\)
- \(1 + 1 + 1 + 1 + 1\)
So \(p(5) = 7\). Partitions into distinct parts: \(\{5\}, \{4+1\}, \{3+2\}\) — three of them, so \(q(5) = 3\). Partitions into odd parts: \(\{5\}, \{3+1+1\}, \{1+1+1+1+1\}\) — also three, so \(o(5) = 3\). Euler's theorem holds. Finally, \(n = 5 \equiv 0 \pmod 5\) is not of the form \(5k+4\), so the \(5\)-congruence does not apply; however, \(p(4) = 5\) does satisfy \(p(5k+4) \equiv 0 \pmod 5\).
Classic Values of p(n)
| n | p(n) | Note |
|---|---|---|
| 0 | 1 | Empty partition (convention) |
| 1 | 1 | Single partition: {1} |
| 5 | 7 | First prime-indexed example |
| 10 | 42 | "The Answer" |
| 20 | 627 | |
| 50 | 204,226 | |
| 100 | 190,569,292 | Computed by MacMahon by hand, 1915 |
| 200 | 3,972,999,029,388 | |
| 500 | 2,300,165,032,574,323,995,027 | Approximately \(2.3 \times 10^{21}\) |
History
- 1750s: Leonhard Euler studies partitions and discovers the generating function identity and the "distinct = odd" theorem.
- 1915: Major Percy MacMahon publishes a table of \(p(n)\) for \(n\) up to 200 — computed by hand.
- 1918: Hardy and Ramanujan prove the asymptotic formula using the circle method.
- 1919: Ramanujan publishes the famous congruences \(p(5k+4),\ p(7k+5),\ p(11k+6)\).
- 1937: Hans Rademacher refines Hardy-Ramanujan into an exact convergent series.
- 2011: Ken Ono and Jan Bruinier prove that \(p(n)\) can be expressed as a finite algebraic sum at every positive integer.
Applications
- Combinatorics and representation theory — partitions index irreducible representations of the symmetric group \(S_n\).
- Statistical mechanics — partition counts appear in the entropy of ideal quantum gases and in string-theory partition functions.
- Modular forms — the generating function for \(p(n)\) is closely related to the Dedekind eta function.
- Computer science — subset-sum and integer-programming enumeration benchmarks frequently use partition counts.
Frequently Asked Questions
What is the partition function p(n)?
\(p(n)\) counts the number of ways to express \(n\) as a sum of positive integers where order does not matter. \(p(4) = 5\) because 4 can be written as \(4\), \(3+1\), \(2+2\), \(2+1+1\), or \(1+1+1+1\). By convention \(p(0) = 1\).
What is a Young or Ferrers diagram?
A Young diagram is a visual representation of a partition: each part becomes a row of left-justified boxes, with parts listed from largest to smallest top to bottom. For \(4+2+1\), draw a row of 4, a row of 2, and a row of 1. This calculator renders a Young diagram for every partition when \(n \le 15\).
What does Euler's partition theorem say?
For every positive integer \(n\), the number of partitions of \(n\) into distinct parts equals the number of partitions of \(n\) into odd parts. For \(n = 5\): distinct parts give \(\{5\}, \{4+1\}, \{3+2\}\); odd parts give \(\{5\}, \{3+1+1\}, \{1+1+1+1+1\}\). Both counts equal 3.
What is the Hardy-Ramanujan asymptotic formula?
It states that \(p(n) \sim \frac{1}{4n\sqrt{3}} \exp\!\left(\pi \sqrt{2n/3}\right)\) as \(n \to \infty\). This was the first formula to describe the exact rate of growth of \(p(n)\), discovered in 1918 by G.H. Hardy and Srinivasa Ramanujan.
What are Ramanujan's partition congruences?
Three remarkable divisibility patterns: \(p(5k+4) \equiv 0 \pmod 5\), \(p(7k+5) \equiv 0 \pmod 7\), and \(p(11k+6) \equiv 0 \pmod{11}\). For example, \(p(4)=5, p(9)=30, p(14)=135\) are all divisible by 5.
How fast does p(n) grow?
p(n) grows sub-exponentially but faster than any polynomial, roughly like \(\exp(\pi \sqrt{2n/3})\). For comparison: \(p(10)=42\), \(p(50)=204{,}226\), \(p(100)=190{,}569{,}292\), and \(p(200) \approx 4 \times 10^{12}\). Use the chart's log-scale toggle to visualise this growth curve.
Additional Resources
Reference this content, page, or tool as:
"Partition Function Calculator" at https://MiniWebtool.com/partition-function-calculator/ from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: Apr 19, 2026
You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.
Related MiniWebtools:
Sequence Tools:
- Arithmetic Sequence Calculator
- Cube Numbers List
- First n Prime Numbers
- Geometric Sequence Calculator
- List of Fibonacci Numbers
- List of Prime Numbers Featured
- Square Numbers List
- Collatz Conjecture Calculator New
- Happy Number Calculator New
- Magic Square Generator New
- Catalan Number Generator New
- Sigma Notation Calculator (Summation) New
- Product Notation Calculator (Pi Notation) New
- Pascal's Triangle Generator New
- Twin Prime Finder New
- Partition Function Calculator New