Introduction
The partition function is a classic counting tool from number theory. When mathematicians write p(n), they mean the number of different ways to express the integer n as a sum of positive whole numbers, with order ignored. That last phrase matters. For partitions, 4 + 1 and 1 + 4 are the same partition because they use the same parts. This makes partition counting different from counting ordered compositions, where rearrangements would count separately.
This calculator finds the unrestricted partition number for a non-negative integer. If you enter 10, the calculator returns 42, meaning there are 42 unordered partitions of 10. The result is useful in combinatorics, generating functions, q-series, and many areas of pure mathematics. It also appears in physics, especially when counting ways that energy or states can be distributed under certain models. Even though the definition is easy to state, the values grow quickly, and that rapid growth is one reason the partition function is so interesting.
A small example makes the idea concrete. The partitions of 4 are:
4, 3 + 1, 2 + 2, 2 + 1 + 1, and 1 + 1 + 1 + 1.
There are five of them, so p(4) = 5. Notice that we do not list 1 + 3 separately from 3 + 1. The calculator on this page follows exactly that convention.
How to Use the Calculator
Using the calculator is straightforward. Enter a non-negative integer in the input box labeled Integer to Partition (n), then press Calculate Partitions. The result panel will show the value of n, the partition count p(n), and the computation time in milliseconds. The copy button lets you quickly save the result for notes, homework, or research.
Here is the practical meaning of the input and output:
Input n: the target integer you want to break into sums of positive integers.
Output p(n): the number of unordered partitions of that integer.
Computation time: how long the browser took to compute the answer on your device.
The calculator accepts values from 0 to 1000 in the form field. At n = 0, the standard convention is p(0) = 1. That may seem surprising at first, but it reflects the fact that there is exactly one way to partition zero: using no parts at all, often called the empty partition. This convention is essential because it makes the recurrence relations and generating functions work cleanly.
If you are checking your intuition, try a few small values first. For example, enter 5 and confirm that the result is 7. Then try 10 and see how quickly the count grows. By the time you reach 50, the number of partitions is already 204,226. The calculator is especially helpful once manual listing becomes unrealistic.
Understanding the Partition Function
The partition function sits at the intersection of simple definitions and deep mathematics. On the surface, it is just a counting problem: how many unordered sums make up a number? But the sequence of values reveals rich structure. Mathematicians have studied partitions for centuries because they connect to generating functions, modular forms, congruences, asymptotic analysis, and representation theory.
One reason partitions are so elegant is that they turn arithmetic into geometry and algebra. A partition can be drawn as a Ferrers diagram or Young diagram, where each part becomes a row of dots or boxes. That visual viewpoint helps explain why partitions appear in the representation theory of symmetric groups and in the study of symmetric functions. The same counting problem can be approached numerically, visually, algebraically, or analytically.
Mathematical Background
Leonhard Euler gave the subject its foundational generating function, and later mathematicians such as Hardy, Ramanujan, and Rademacher uncovered astonishing properties of p(n). Ramanujan discovered famous congruences, including the fact that p(5k + 4) is divisible by 5, p(7k + 5) is divisible by 7, and p(11k + 6) is divisible by 11. These patterns are not obvious from the definition alone, which is part of what makes partition theory so beautiful.
In practical computation, the partition function is often evaluated by recurrence or dynamic programming. This page uses a reliable dynamic programming method that builds the answer from smaller integers. It is not changing the mathematics; it is simply an efficient way to count all valid unordered sums without listing them explicitly.
The Partition Function Formula
The generating function for p(n) is Euler's infinite product, and one of the most important recurrences comes from the pentagonal number theorem. The MathML formula below is preserved from the original page and expresses that recursive structure:
The terms k(3k − 1)/2 and k(3k + 1)/2 are generalized pentagonal numbers. They determine which earlier partition values are added and subtracted in the recurrence. Although the formula looks advanced, the basic idea is simple: the value of p(n) can be built from earlier values of p for smaller integers.
Another useful viewpoint is Euler's generating function:
the coefficient of xn in
1 / ((1 − x)(1 − x²)(1 − x³)(1 − x⁴) ...)
is exactly p(n). Each factor represents how many times a part size may be used. Expanding the product encodes every possible partition.
Worked Example
Suppose you want to compute p(5). The partitions of 5 are:
- 5
- 4 + 1
- 3 + 2
- 3 + 1 + 1
- 2 + 2 + 1
- 2 + 1 + 1 + 1
- 1 + 1 + 1 + 1 + 1
There are seven partitions, so p(5) = 7. If you enter 5 into the calculator, you should see that same result immediately. This is a good test case because it is still small enough to verify by hand.
Here is another quick example. For n = 6, the partitions are 6, 5 + 1, 4 + 2, 4 + 1 + 1, 3 + 3, 3 + 2 + 1, 3 + 1 + 1 + 1, 2 + 2 + 2, 2 + 2 + 1 + 1, 2 + 1 + 1 + 1 + 1, and 1 + 1 + 1 + 1 + 1 + 1. That gives p(6) = 11. Small examples like this help build intuition before you move to larger values where direct listing is no longer practical.
How the Calculator Computes the Result
The JavaScript on this page uses dynamic programming. It starts with an array of partition counts and sets the base case p(0) = 1. Then, for each possible part size from 1 up to n, it updates the number of ways to build every larger total. Because the loop processes part sizes in increasing order, each unordered partition is counted once. That is exactly what we want.
This method is efficient for the range used here and is easy to trust because it mirrors the combinatorial meaning of partitions. It does not rely on floating-point approximations, so the values are exact within the supported range. For very large n, more advanced methods exist, but for a browser calculator this approach is a strong balance of clarity and speed.
Interpreting the Result
When the calculator returns a value such as p(20) = 627, it means there are 627 unordered additive decompositions of 20 into positive integers. It does not mean 627 ordered sums, and it does not impose restrictions such as distinct parts, odd parts, prime parts, or a fixed number of summands. If you need one of those restricted counting problems, you would use a different function or a modified algorithm.
The result also grows much faster than many people expect. Partition numbers are not merely linear or polynomial in size. They increase rapidly, which is why even moderate inputs can produce large outputs. This growth is one reason asymptotic formulas, such as the Hardy–Ramanujan approximation, are so important in analytic number theory.
Assumptions and Limitations
This calculator computes unrestricted integer partitions of a non-negative integer. It assumes:
- all parts are positive integers,
- order does not matter,
- repetition of parts is allowed, and
- the input is a whole number in the supported range.
It does not directly compute partitions into distinct parts, partitions into odd parts, partitions with a fixed number of parts, or partitions subject to upper and lower bounds. Those are important related problems, but they are different calculators mathematically.
For large values, the count can become very large very quickly. The page still computes exact values for the allowed input range, but the interpretation remains the same: the answer is a count of unordered sums, not a probability, not a percentage, and not a physical partition function from thermodynamics. The same phrase “partition function” is used in physics, but in this calculator the meaning is specifically the integer partition function p(n).
Applications and Significance
Partition numbers appear in combinatorics, algebra, and mathematical physics. In combinatorics, they help count structured arrangements and support generating-function methods. In algebra, partitions index irreducible representations of symmetric groups and organize Young tableaux. In q-series and modular forms, partition generating functions become gateways to deeper analytic results. In statistical mechanics, related counting ideas help describe distributions of states, although the exact object used in physics is usually a different kind of partition function.
For students, the partition function is a great example of how a simple question can lead to advanced mathematics. For researchers, it remains an active area with links to congruences, modularity, asymptotics, and algorithm design. For anyone using this calculator casually, it offers a fast way to explore a famous integer sequence and see how quickly combinatorial complexity grows.
Partition Values for Common Integers
These sample values give a quick sense of how fast the partition function grows. They are useful checkpoints if you want to test the calculator or compare nearby inputs.
| n | p(n) | Description |
|---|---|---|
| 1 | 1 | Only one partition: 1 |
| 3 | 3 | Three partitions: 3, 2 + 1, 1 + 1 + 1 |
| 5 | 7 | A classic small example that is easy to verify by hand |
| 10 | 42 | The count is already much larger than most people expect |
| 20 | 627 | Hundreds of unordered partitions |
| 50 | 204,226 | Rapid growth becomes unmistakable |
Results
Partition Collector Mini-Game
Want a playful way to build intuition? In this optional mini-game, your goal is to collect falling number tiles so their sum matches the target integer. Every exact match creates one valid partition, boosts your streak, and raises the pace. Overshooting the target costs energy, so you need to think like the calculator: combine parts carefully, ignore order, and complete as many partitions as you can before time runs out.
