Skip to main content

Partition Function Calculator

Solve partition function problems step-by-step with our free calculator. See formulas, worked examples, and clear explanations.

Skip to calculator
Mathematics

Partition Function Calculator

Calculate the integer partition function p(n) using dynamic programming. Explore partition counts, distinct and odd partitions, Ramanujan congruences, and Hardy-Ramanujan approximations.

Last updated: December 2025Reviewed by NovaCalculator Mathematics Team

Calculator

Adjust values & calculate
p(10)
Partitions of 10
42
Distinct Parts
10
Odd Parts
10
Hardy-Ramanujan Approx.
48
Error: 14.53%
Euler Identity Holds?
Yes
Distinct = Odd parts

Partitions of 10 (first 42)

10
9 + 1
8 + 2
8 + 1 + 1
7 + 3
7 + 2 + 1
7 + 1 + 1 + 1
6 + 4
6 + 3 + 1
6 + 2 + 2
6 + 2 + 1 + 1
6 + 1 + 1 + 1 + 1
5 + 5
5 + 4 + 1
5 + 3 + 2
5 + 3 + 1 + 1
5 + 2 + 2 + 1
5 + 2 + 1 + 1 + 1
5 + 1 + 1 + 1 + 1 + 1
4 + 4 + 2
4 + 4 + 1 + 1
4 + 3 + 3
4 + 3 + 2 + 1
4 + 3 + 1 + 1 + 1
4 + 2 + 2 + 2
4 + 2 + 2 + 1 + 1
4 + 2 + 1 + 1 + 1 + 1
4 + 1 + 1 + 1 + 1 + 1 + 1
3 + 3 + 3 + 1
3 + 3 + 2 + 2
3 + 3 + 2 + 1 + 1
3 + 3 + 1 + 1 + 1 + 1
3 + 2 + 2 + 2 + 1
3 + 2 + 2 + 1 + 1 + 1
3 + 2 + 1 + 1 + 1 + 1 + 1
3 + 1 + 1 + 1 + 1 + 1 + 1 + 1
2 + 2 + 2 + 2 + 2
2 + 2 + 2 + 2 + 1 + 1
2 + 2 + 2 + 1 + 1 + 1 + 1
2 + 2 + 1 + 1 + 1 + 1 + 1 + 1
2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1

Partition Table p(0) to p(10)

p(0)1
p(1)1
p(2)2
p(3)3
p(4)5
p(5)7
p(6)11
p(7)15
p(8)22
p(9)30
p(10)42
Your Result
p(10) = 42 | Distinct parts: 10 | Odd parts: 10
Share Your Result
Understand the Math

Formula

p(n) = number of ways to write n as a sum of positive integers

The partition function p(n) counts unordered representations of n as sums of positive integers. The Hardy-Ramanujan asymptotic formula approximates p(n) as (1/(4n*sqrt(3))) * exp(pi*sqrt(2n/3)). Dynamic programming computes exact values efficiently.

Last reviewed: December 2025

Worked Examples

Example 1: Computing p(10) - Partitions of 10

Find the number of ways to partition the integer 10 into sums of positive integers.
Solution:
Using dynamic programming: dp[0]=1, then add each part size 1 through 10. After processing all parts: dp[10] = 42 Some partitions: 10, 9+1, 8+2, 7+3, 7+2+1, 6+4, 6+3+1, ... Distinct-part partitions: 10, 9+1, 8+2, 7+3, 7+2+1, 6+3+1, 5+4+1, 5+3+2, 4+3+2+1 = 10 Odd-part partitions: also 10 (Euler identity confirmed)
Result: p(10) = 42 | Distinct parts: 10 | Odd parts: 10 | Hardy-Ramanujan estimate: 48

Example 2: Verifying Ramanujan Congruence p(5n+4) mod 5 = 0

Check that p(4), p(9), p(14), and p(19) are all divisible by 5.
Solution:
p(4) = 5 = 5 * 1 p(9) = 30 = 5 * 6 p(14) = 135 = 5 * 27 p(19) = 490 = 5 * 98 All are divisible by 5, confirming the congruence.
Result: p(4)=5, p(9)=30, p(14)=135, p(19)=490 - all divisible by 5
Expert Insights

Background & Theory

The Partition Function Calculator applies the following established principles and formulas. Mathematics rests on a hierarchy of number systems, each extending the previous. The natural numbers (1, 2, 3, ...) support counting and ordering. The integers add negative values and zero, enabling subtraction without restriction. The rational numbers, expressible as p/q where p and q are integers and q is nonzero, close the system under division. The real numbers fill the gaps left by irrationals such as the square root of 2 or pi, forming a complete ordered field. The complex numbers, written as a + bi where i is the square root of negative one, complete the algebraic closure of the reals and allow every polynomial to have a root. Prime factorization states that every integer greater than one is uniquely expressible as a product of primes, a result known as the Fundamental Theorem of Arithmetic. Computing the greatest common divisor (GCD) of two integers relies most efficiently on the Euclidean algorithm: repeatedly replace the larger number with the remainder when it is divided by the smaller, until the remainder is zero. The last nonzero remainder is the GCD. The least common multiple (LCM) follows from the identity LCM(a, b) = |a * b| / GCD(a, b). Modular arithmetic defines equivalence classes of integers that share the same remainder under division by a modulus n. Fermat's Little Theorem and Euler's Theorem arise from this structure and underpin modern cryptography. Logarithms are the inverses of exponential functions. If b raised to the power x equals y, then the logarithm base b of y equals x. The natural logarithm uses base e, approximately 2.71828. Combinatorics counts arrangements and selections. The number of ordered arrangements (permutations) of r objects from n distinct objects is nPr = n! / (n - r)!. The number of unordered selections (combinations) is nCr = n! / (r! * (n - r)!). Pascal's triangle arranges these binomial coefficients so that each entry equals the sum of the two entries directly above it. The Fibonacci sequence, defined by F(1) = 1, F(2) = 1, and F(n) = F(n-1) + F(n-2), appears throughout nature and connects deeply to the golden ratio via Binet's formula.

History

The history behind the Partition Function Calculator traces back through the following developments. Mathematics as a systematic discipline traces to ancient Mesopotamia. Babylonian clay tablets dating to around 1800 BCE demonstrate knowledge of quadratic equations, Pythagorean triples, and base-60 arithmetic, suggesting a practical mathematical tradition far preceding Greek formalism. Euclid of Alexandria compiled the Elements around 300 BCE, establishing the axiomatic method that would define rigorous mathematics for over two thousand years. His work organized plane geometry, number theory, and proportion into logically chained propositions derived from a small set of postulates. The algorithm bearing his name for computing GCDs appears in Book VII and remains in use today. In the 9th century, the Persian scholar Muhammad ibn Musa Al-Khwarizmi wrote Al-Kitab al-mukhtasar fi hisab al-jabr wal-muqabala, the treatise whose title gave algebra its name. He systematized the solution of linear and quadratic equations and described procedures that operated on unknowns as objects, a conceptual leap away from purely numerical calculation. Rene Descartes introduced coordinate geometry in 1637 by uniting algebra and Euclidean geometry, allowing curves to be studied through equations. This synthesis set the stage for calculus. Isaac Newton and Gottfried Wilhelm Leibniz independently developed calculus during the 1660s and 1670s, triggering a priority dispute that lasted decades and divided British and Continental mathematicians. Carl Friedrich Gauss proved the Fundamental Theorem of Algebra in 1799, showing that every nonconstant polynomial has at least one complex root. His Disquisitiones Arithmeticae of 1801 established modern number theory. David Hilbert's formalist program at the turn of the 20th century sought to place all of mathematics on an explicit axiomatic foundation, a project that Kurt Godel's incompleteness theorems of 1931 showed to be fundamentally limited. Alan Turing's work in the 1930s on computability introduced the theoretical model of the stored-program computer and linked mathematical logic directly to the limits of algorithmic calculation. His proof that no algorithm can decide in general whether an arbitrary program will halt or run forever placed fundamental boundaries on what mathematics can mechanically determine, and it opened the discipline now known as theoretical computer science.

Share this calculator

Explore More

Frequently Asked Questions

The partition function p(n) counts the number of distinct ways a positive integer n can be written as a sum of positive integers, where the order of summands does not matter. For example, p(4) = 5 because 4 can be partitioned as 4, 3+1, 2+2, 2+1+1, and 1+1+1+1. The function grows extremely rapidly: p(10) = 42, p(50) = 204,226, and p(100) = 190,569,292,356. The partition function was studied extensively by Euler, Hardy, Ramanujan, and Rademacher, and it connects to deep areas of modular forms, combinatorics, and representation theory. It has applications in statistical mechanics and quantum physics.
Euler proved that for any positive integer n, the number of partitions into distinct parts equals the number of partitions into odd parts. For example, for n = 5: the distinct partitions are 5, 4+1, 3+2, giving 3 partitions; the odd-part partitions are 5, 3+1+1, 1+1+1+1+1, also giving 3. This elegant identity can be proven using generating functions, where the generating function for distinct partitions is the product of (1+x^k) for k = 1,2,3,..., which equals the product of 1/(1-x^(2k-1)), the generating function for odd partitions. This identity is one of the foundational results in the theory of integer partitions and combinatorial identities.
Ramanujan discovered remarkable divisibility patterns in the partition function. He proved that p(5n+4) is always divisible by 5, p(7n+5) is always divisible by 7, and p(11n+6) is always divisible by 11. For example, p(4) = 5, p(9) = 30, p(14) = 135, and p(19) = 490 are all divisible by 5. These congruences were later understood as consequences of deep properties of modular forms. Ken Ono and others extended these results, showing that for any prime m >= 5, there are infinitely many congruences of the form p(An+B) divisible by m. These discoveries reveal that the partition function has hidden periodic structure governed by modular arithmetic.
The rank of a partition, defined by Freeman Dyson in 1944, is the largest part minus the number of parts. Dyson conjectured that the rank modulo 5 and modulo 7 would explain Ramanujan first two congruences, which was later proved by Atkin and Swinnerton-Dyer. However, the rank fails to explain the modulo 11 congruence. To resolve this, Dyson hypothesized a statistic he called the crank, which was eventually discovered by Andrews and Garvan in 1988. The crank is defined as the largest part if no 1s appear in the partition, or as the number of parts larger than the number of 1s minus the number of 1s. The crank modulo 5, 7, and 11 simultaneously explains all three Ramanujan congruences.
You may use the results for reference and educational purposes. For professional reports, academic papers, or critical decisions, we recommend verifying outputs against peer-reviewed sources or consulting a qualified expert in the relevant field.
All calculations use established mathematical formulas and are performed with high-precision arithmetic. Results are accurate to the precision shown. For critical decisions in finance, medicine, or engineering, always verify results with a qualified professional.
Educational Note: This calculator is provided for educational and informational purposes. Results are based on the formulas and inputs provided. Always verify important calculations independently. NovaCalculator processes calculator inputs client-side; optional analytics follow visitor consent settings.Reviewed by: NovaCalculator Mathematics Team โ€” Verified against standard mathematical and scientific references. Last reviewed: December 2025. ยฉ 2024โ€“2026 NovaCalculator.

Share this calculator

Formula

p(n) = number of ways to write n as a sum of positive integers

The partition function p(n) counts unordered representations of n as sums of positive integers. The Hardy-Ramanujan asymptotic formula approximates p(n) as (1/(4n*sqrt(3))) * exp(pi*sqrt(2n/3)). Dynamic programming computes exact values efficiently.

Worked Examples

Example 1: Computing p(10) - Partitions of 10

Problem: Find the number of ways to partition the integer 10 into sums of positive integers.

Solution: Using dynamic programming:\ndp[0]=1, then add each part size 1 through 10.\nAfter processing all parts: dp[10] = 42\nSome partitions: 10, 9+1, 8+2, 7+3, 7+2+1, 6+4, 6+3+1, ...\nDistinct-part partitions: 10, 9+1, 8+2, 7+3, 7+2+1, 6+3+1, 5+4+1, 5+3+2, 4+3+2+1 = 10\nOdd-part partitions: also 10 (Euler identity confirmed)

Result: p(10) = 42 | Distinct parts: 10 | Odd parts: 10 | Hardy-Ramanujan estimate: 48

Example 2: Verifying Ramanujan Congruence p(5n+4) mod 5 = 0

Problem: Check that p(4), p(9), p(14), and p(19) are all divisible by 5.

Solution: p(4) = 5 = 5 * 1\np(9) = 30 = 5 * 6\np(14) = 135 = 5 * 27\np(19) = 490 = 5 * 98\nAll are divisible by 5, confirming the congruence.

Result: p(4)=5, p(9)=30, p(14)=135, p(19)=490 - all divisible by 5

Frequently Asked Questions

What is the partition function p(n) in number theory?

The partition function p(n) counts the number of distinct ways a positive integer n can be written as a sum of positive integers, where the order of summands does not matter. For example, p(4) = 5 because 4 can be partitioned as 4, 3+1, 2+2, 2+1+1, and 1+1+1+1. The function grows extremely rapidly: p(10) = 42, p(50) = 204,226, and p(100) = 190,569,292,356. The partition function was studied extensively by Euler, Hardy, Ramanujan, and Rademacher, and it connects to deep areas of modular forms, combinatorics, and representation theory. It has applications in statistical mechanics and quantum physics.

What is Euler distinct-odd partition theorem?

Euler proved that for any positive integer n, the number of partitions into distinct parts equals the number of partitions into odd parts. For example, for n = 5: the distinct partitions are 5, 4+1, 3+2, giving 3 partitions; the odd-part partitions are 5, 3+1+1, 1+1+1+1+1, also giving 3. This elegant identity can be proven using generating functions, where the generating function for distinct partitions is the product of (1+x^k) for k = 1,2,3,..., which equals the product of 1/(1-x^(2k-1)), the generating function for odd partitions. This identity is one of the foundational results in the theory of integer partitions and combinatorial identities.

What are Ramanujan congruences for the partition function?

Ramanujan discovered remarkable divisibility patterns in the partition function. He proved that p(5n+4) is always divisible by 5, p(7n+5) is always divisible by 7, and p(11n+6) is always divisible by 11. For example, p(4) = 5, p(9) = 30, p(14) = 135, and p(19) = 490 are all divisible by 5. These congruences were later understood as consequences of deep properties of modular forms. Ken Ono and others extended these results, showing that for any prime m >= 5, there are infinitely many congruences of the form p(An+B) divisible by m. These discoveries reveal that the partition function has hidden periodic structure governed by modular arithmetic.

What is the rank and crank of a partition?

The rank of a partition, defined by Freeman Dyson in 1944, is the largest part minus the number of parts. Dyson conjectured that the rank modulo 5 and modulo 7 would explain Ramanujan first two congruences, which was later proved by Atkin and Swinnerton-Dyer. However, the rank fails to explain the modulo 11 congruence. To resolve this, Dyson hypothesized a statistic he called the crank, which was eventually discovered by Andrews and Garvan in 1988. The crank is defined as the largest part if no 1s appear in the partition, or as the number of parts larger than the number of 1s minus the number of 1s. The crank modulo 5, 7, and 11 simultaneously explains all three Ramanujan congruences.

What inputs do I need to use Partition Function Calculator accurately?

Each field is labelled with the required unit (metric or imperial). Gather your source values before starting โ€” for example, a weight measurement in kilograms, a distance in metres, or a dollar amount โ€” and enter them exactly as measured. The formula section on this page lists every variable and explains what each represents.

Does Partition Function Calculator work offline?

Once the page is loaded, the calculation logic runs entirely in your browser. If you have already opened the page, most calculators will continue to work even if your internet connection is lost, since no server requests are needed for computation.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy