Partition Number Calculator
Count the ways to write an integer as a sum of positive parts, with order ignored and the previous value shown.
What it does
A partition of an integer is a way of writing it as a sum of positive integers. The order of the terms is ignored, so 4 + 1 and 1 + 4 count as the same partition. For ten there are forty two partitions, ranging from ten ones down to the single term ten itself.
This is a different idea from the partitions of a set counted by Bell numbers. Here the parts are positive integers with no labels, and the only question is which multiset of values appears. The function p(n) records how many such multisets exist.
Leonhard Euler found a recurrence based on generalized pentagonal numbers. These are the values k times three k minus one over two, and k times three k plus one over two, taken for k equals one, two, three and so on. The signs alternate in pairs, which makes the recurrence short compared with listing every partition.
This page applies that recurrence in order, so every p value used on the right hand side is already final. It reports p(n), the previous value and the ratio between them. At n = 200 the count is over three trillion, and the tool still prints the exact integer.
The input limit is 200. That is far beyond hand counting, but small enough that the browser returns the answer immediately. No list of partitions is produced, only the count.
How to use
- Enter a whole number n from 0 to 200.
- Read p(n) from the main result box.
- Check the previous value to compare adjacent counts.
- Use the growth ratio to see how the sequence accelerates.
- The default n = 10 reproduces the worked example.
- Try n = 20 to confirm the value 627.
Formula
- n
- The integer being partitioned.
- g1, g2
- The generalized pentagonal numbers for the current k.
- p(n)
- The number of unordered sums of positive integers totaling n.
The generalized pentagonal numbers begin 1, 2, 5, 7, 12 and 15. Their signs come in pairs: plus for k = 1, minus for k = 2, plus for k = 3, and so on. Terms with a negative argument are skipped. The empty sum for n = 0 is defined as the single empty partition, so p(0) = 1.
Worked example
Example: p(10)
The page opens with n = 10, the default value.
- List the pentagonal numbers up to 10: 1, 2, 5 and 7.
- Assign signs: plus for 1 and 2, minus for 5 and 7.
- Write the recurrence: p(10) = p(9) + p(8) - p(5) - p(3).
- Look up the earlier values: p(9) = 30, p(8) = 22, p(5) = 7 and p(3) = 3.
- Add and subtract: 30 + 22 - 7 - 3 = 42.
- The tool reports 42 partitions, previous value 30, and growth 1.40x.
- Check a smaller case: p(5) = p(4) + p(3) - p(0) = 5 + 3 - 1 = 7.
Reference table
| n | p(n) | Previous | Growth |
|---|---|---|---|
| 0 | 1 | n/a | n/a |
| 3 | 3 | 2 | 1.50x |
| 5 | 7 | 5 | 1.40x |
| 10 | 42 | 30 | 1.40x |
| 20 | 627 | 490 | 1.28x |
| 50 | 204226 | 173525 | 1.18x |
Limits
- The order of summands is ignored, so 2 + 3 and 3 + 2 are one partition.
- Zero and negative parts are not allowed.
- Inputs above 200 are rejected to keep the output integer manageable.
- The tool counts partitions without listing them.
Common mistakes
- Counting ordered compositions instead of unordered partitions.
- Using the ordinary pentagonal numbers and forgetting the second family.
- Repeating a sign instead of alternating it for consecutive k.
- Including a term with a negative index in the sum.
- Assuming p(n) is always odd for odd n.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is p(5)?
p(5) = 7, from the partitions 5, 4+1, 3+2, 3+1+1, 2+2+1, 2+1+1+1 and 1+1+1+1+1.
What is p(20)?
p(20) = 627, with p(19) = 490 before it.
What is p(0)?
p(0) = 1, counting the empty partition of the integer zero.
Questions
How is this different from set partitions?
Integer partitions split a number into summands, while set partitions split labeled elements into groups.
Why is p(0) equal to 1?
There is one way to write zero as a sum of positive integers, which is to use no terms at all.
What are generalized pentagonal numbers?
The values k(3k minus 1)/2 and k(3k plus 1)/2 for k equal to one, two, three and onward.
Does p(n) grow quickly?
Yes. It reaches 42 at ten, 627 at twenty and over two hundred thousand at fifty.
Are the values exact?
Yes. The recurrence uses only integer addition and subtraction.
What is the largest input?
Two hundred. Larger entries return a readable error message.