Integer Partition Calculator

Count, list, and visualize integer partitions with constraints and Ferrers diagrams.

Results are calculated automatically as you enter data.

Formula and interpretation
Partition count Enter n to count partitions.

Ferrers diagrams are visual examples only; the partition count and listed partitions below provide the equivalent text result.

▼ See explanations and tips below ▼

What Are Restricted Integer Partitions?

An integer partition is a way to write a nonnegative integer as a sum of positive integers, without treating different orders as different answers. For example, \(4\) has five unrestricted partitions:

$$ 4,\quad 3+1,\quad 2+2,\quad 2+1+1,\quad 1+1+1+1 $$

The order of the parts does not matter, so \(3+1\) and \(1+3\) are the same partition. To avoid repeats, partitions are usually written with the largest part first.

A restricted integer partition adds rules to the basic idea. Common restrictions include allowing only parts up to a maximum value, requiring exactly \(k\) parts, or requiring all parts to be distinct. These restrictions change the count because they remove some sums that would otherwise be valid.

Integer partitions are useful because they turn “how many ways can this total be built?” into a precise counting question. They appear in combinatorics, number theory, algebra, probability, and computer algorithms, and they are also a good way to learn how constraints affect a counting problem.


Why Integer Partitions Matter

Integer partitions help separate two important ideas: choosing values and arranging values. In a partition, the values matter, but their order does not. This makes partitions different from ordered lists, schedules, sequences, or step-by-step arrangements.

That distinction is useful in many settings:

  • In mathematics, partitions are a central example in combinatorics and generating functions.
  • In teaching, they show how a simple counting question can grow quickly as \(n\) increases.
  • In algorithms, they provide a natural example of recursion and dynamic programming.
  • In visualization, Ferrers diagrams turn a sum into a geometric shape, making hidden relationships easier to see.

Restrictions make the topic more practical. For example, “partition \(8\) into exactly three parts, each no larger than \(5\)” is more specific than simply asking for all partitions of \(8\).


Key Terms to Know

  • Partition: An unordered sum of positive integers that equals a target nonnegative integer.
  • Part: One positive integer in the sum. In \(5+2+1\), the parts are \(5\), \(2\), and \(1\).
  • Partition function: The function usually written \(p(n)\), which counts the unrestricted partitions of \(n\).
  • Restricted partition: A partition that must satisfy one or more added conditions, such as a maximum part size or an exact number of parts.
  • Distinct parts: A rule that each part size can appear at most once. For example, \(5+2+1\) has distinct parts, but \(4+2+2\) does not.
  • Exact number of parts: A rule requiring the partition to use exactly \(k\) summands.
  • Maximum part: The largest allowed value for any part in the partition.
  • Composition: An ordered sum. Compositions count different orders separately, so they are not the same as partitions.
  • Generating function: A power series whose coefficients encode the counts of a sequence or counting problem.
  • Coefficient extraction: The notation \([x^n]F(x)\), meaning “the coefficient of \(x^n\) in \(F(x)\).”
  • Ferrers diagram: A block or dot diagram for a partition, with one row for each part and one cell for each unit in that part.

How Restricted Integer Partitions Work

A partition count can be built recursively. Start with the total still remaining. Choose a next part that is no larger than the current maximum allowed part. Subtract that part from the remaining total, then repeat.

Writing parts from largest to smallest is what prevents overcounting. Once a partition starts with \(4\), the next part may be \(4\) or smaller when repeated parts are allowed. If distinct parts are required, the next part must be strictly smaller.

For example, to partition \(8\) with repeated parts allowed, a branch that starts with \(5\) continues by partitioning the remaining total \(3\) using parts no larger than \(5\). If distinct parts are required, after choosing \(5\), the next allowed part is at most \(4\).

Generating functions give a compact algebraic way to describe the same counting problem. If parts up to \(M\) are allowed and repeated parts may be used, the count is the coefficient of \(x^n\) in this product:

$$ P_{\le M}(n) = [x^n]\prod_{i=1}^{M}\frac{1}{1-x^i} $$

The factor for part size \(i\) represents using \(0,1,2,3,\ldots\) copies of that part size.

If the partition must use exactly \(k\) parts, a second variable can track how many parts are chosen:

$$ P_{\le M,k}(n) = [x^n y^k]\prod_{i=1}^{M}\frac{1}{1-yx^i} $$

If each part size may be used at most once, each part size is either included or not included:

$$ D_{\le M}(n) = [x^n]\prod_{i=1}^{M}(1+x^i) $$

With both distinct parts and exactly \(k\) parts, the matching coefficient form is:

$$ D_{\le M,k}(n) = [x^n y^k]\prod_{i=1}^{M}(1+yx^i) $$

These formulas do not mean you must multiply out the full product by hand. They explain what the count represents: the coefficient of the term whose exponent matches the target total and, when needed, the number of parts.


Examples of Integer Partitions in Practice

Example 1: Unrestricted partitions of 5

The unrestricted partitions of \(5\) are:

$$ 5 $$
$$ 4+1 $$
$$ 3+2 $$
$$ 3+1+1 $$
$$ 2+2+1 $$
$$ 2+1+1+1 $$
$$ 1+1+1+1+1 $$

So the unrestricted partition count is:

$$ p(5)=7 $$

The sum \(1+4\) is not listed separately, because it is the same partition as \(4+1\).


Example 2: Partitions of 8 into exactly 3 parts with maximum part 5

Now add two restrictions:

  • The total must be \(8\).
  • The partition must use exactly \(3\) parts.
  • No part may be larger than \(5\).

With repeated parts allowed, the matching partitions are:

$$ 5+2+1 $$
$$ 4+3+1 $$
$$ 4+2+2 $$
$$ 3+3+2 $$

So the restricted count is:

$$ 4 $$

The partition \(6+1+1\) is not allowed because \(6\) is larger than the maximum part \(5\). The partition \(5+3\) is not allowed because it has only two parts.


Example 3: Distinct partitions of 8

If all parts must be distinct, repeated part sizes are not allowed. The distinct partitions of \(8\) are:

$$ 8 $$
$$ 7+1 $$
$$ 6+2 $$
$$ 5+3 $$
$$ 5+2+1 $$
$$ 4+3+1 $$

So the distinct-part count is:

$$ 6 $$

The unrestricted partition \(4+2+2\) is excluded because the part \(2\) appears twice.


Example 4: The edge case n = 0

The number \(0\) has one special partition: the empty partition. It uses no positive parts and has sum \(0\).

That means the count for \(n=0\) is compatible with a blank exact-parts setting or an exact-parts value of \(0\):

$$ 0 = \text{empty sum} $$

Mathematically, there is no way to partition \(0\) into one or more positive parts. This calculator accepts Exact parts only from \(0\) through \(n\), so it rejects a larger value with an input message instead of calculating zero.


How to Interpret the Result

The main count is the total number of partitions that match the selected restrictions. It is not necessarily the same as the number of rows shown in the displayed list, because the list can be capped.

Each listed partition is written in descending order. For example, \(5+2+1\) represents the same partition as \(2+5+1\), but only the descending form is shown.

The number of parts tells you how many summands are in a listed partition. For \(5+2+1\), the number of parts is \(3\).

The largest part is the first value in the descending partition. For \(5+2+1\), the largest part is \(5\).

A Ferrers diagram turns each listed partition into rows of cells. A partition such as \(5+2+1\) has one row of \(5\) cells, one row of \(2\) cells, and one row of \(1\) cell. The diagram is a visual representation of the partition, not a frequency chart.

The related \(m\) table compares counts for smaller totals under the same style of restrictions. This helps show how the count changes as the target value changes.


Common Mistakes and Misconceptions

Confusing partitions with compositions. In a partition, order does not matter. In a composition, order does matter. The sums \(5+2+1\), \(5+1+2\), and \(1+5+2\) are one partition but three different ordered arrangements.

Assuming the displayed list is always the full set. The total count can be larger than the displayed list limit. When only part of the list is shown, use the total count as the actual answer.

Entering a decimal and expecting a fractional partition problem. Integer partitions use integers. Decimal, scientific-notation, negative, and out-of-range entries are rejected rather than rounded, truncated, or clamped.

Leaving Exact parts blank when you mean zero parts. A blank exact-parts setting means any number of parts is allowed. To require exactly zero parts, use an exact-parts value of \(0\).

Leaving Max part allowed blank without realizing what it means. A blank maximum part setting allows parts up to the target value \(n\).

Turning on Distinct and expecting repeated parts to remain valid. Distinct mode means each part size may appear at most once. A partition such as \(3+3+2\) is invalid in distinct mode because \(3\) appears twice.

Reading a Ferrers diagram as a graph of frequency. Ferrers diagrams show part sizes as row lengths. They do not show how often each number appears unless you interpret the rows carefully.


When to Use Integer Partitions

Use integer partitions when you need to count unordered ways to break a whole-number total into positive whole-number parts.

They are especially useful when you want to:

  • Count all unordered sums of a nonnegative integer.
  • Compare unrestricted and restricted counting problems.
  • Require exactly a certain number of parts.
  • Limit the largest allowed part.
  • Allow or forbid repeated part sizes.
  • Visualize partitions with Ferrers diagrams.
  • Connect a counting problem to recursion, dynamic programming, or generating functions.

Do not use integer partitions when the order of the terms matters. In that case, you are usually working with compositions or another ordered counting model.


Limitations and Things to Keep in Mind

Integer partitions count unordered sums of positive integers. They do not count ordered arrangements. If order matters, the partition count will be too small for your problem.

The calculator accepts a whole-number target from \(0\) to \(120\). Entries outside that range, and entries that are not whole numbers, are rejected with an input message rather than adjusted.

The displayed partition list is capped. The list limit controls how many examples are shown, not the total number of matching partitions. The total count is still the main result.

The maximum displayed list limit is \(200\) partitions. Ferrers diagrams are shown only for the first few listed partitions, so they are a sample visualization rather than a diagram of every matching partition.

Decimal inputs are not interpreted as fractional partition problems. They are rejected before calculation; the calculator does not truncate numeric inputs to whole numbers.

The available restrictions cover maximum part size, exact number of parts, and distinct parts. Other possible restrictions, such as minimum part size, odd parts only, even parts only, excluded part sizes, or “at most \(k\) parts,” are not separate options here.

For classroom work, proofs, or published results, double-check the exact convention being used. Some books and courses use slightly different notation for partition functions, diagrams, and restricted counts.


How to Use This Calculator

  1. Enter the target integer \(n\).
  2. Leave Exact parts blank to allow any number of parts, or enter a nonnegative integer to require exactly that many parts.
  3. Leave Max part allowed blank to allow parts up to \(n\), or enter the largest part value you want to allow.
  4. Check Distinct if each part size may be used at most once. Leave it unchecked if repeated parts are allowed.
  5. Set the displayed list limit if you want to show fewer or more examples.
  6. Review the total count first, then use the listed partitions, Ferrers diagrams, and related count table to understand the result.
  7. Use the graph download option when a Ferrers diagram is shown and you want to save it as a PNG.

Frequently Asked Questions

Is \(3+2\) different from \(2+3\)?

No. For integer partitions, order does not matter. Both sums use the same parts and represent the same partition of \(5\).


What is the difference between a partition and a composition?

A partition is an unordered sum, while a composition is an ordered sum. The values \(4+1\) and \(1+4\) are one partition but two different compositions.


What does “distinct parts” mean?

Distinct parts means no part size can be repeated. For example, \(5+2+1\) is allowed, but \(4+2+2\) is not because the part \(2\) appears twice.


Why can \(n=0\) have one partition?

By convention, \(0\) has one empty partition. It is the empty sum: no positive parts are used, and the total is \(0\).


Does the displayed list limit change the total count?

No. The displayed list limit controls how many matching partitions are shown as examples. The total count still represents all matching partitions under the selected restrictions.


What happens if I enter an exact part count larger than \(n\)?

Mathematically, no partition of a positive \(n\) can have more than \(n\) positive parts. This calculator validates Exact parts from \(0\) through \(n\), so a larger value is rejected with an input message instead of being calculated as zero.


Sources and References

Books

  1. George E. Andrews and Kimmo Eriksson. Integer Partitions. Cambridge University Press, 2004. Introductory chapters on partition definitions, Ferrers diagrams, restricted partitions, and generating functions. Cambridge University Press
  2. Richard P. Stanley. Enumerative Combinatorics, Volume 1. 2nd ed., Cambridge University Press, 2012. Background sections on enumerative methods and ordinary generating functions. Cambridge University Press
  3. Herbert S. Wilf. generatingfunctionology. 2nd ed., Academic Press, 1994. Chapters on ordinary generating functions and coefficient extraction. Download page from Penn Math

Online and Educational Sources

  1. Open Math Books. “Integer Partitions.” More Discrete Mathematics via Graph Theory, accessed June 28, 2026. Open Math Books
  2. Eric W. Weisstein. “Partition Function P.” Wolfram MathWorld, accessed June 28, 2026. Wolfram MathWorld