partition calculator

Integer Partition Calculator

Count how many ways an integer can be written as a sum of positive integers, with optional constraints.

Enter values and click Calculate.

What is a partition in mathematics?

An integer partition of a number is a way of writing it as a sum of positive integers, where order does not matter. For example, the partitions of 4 are: 4, 3+1, 2+2, 2+1+1, and 1+1+1+1. So the partition count of 4 is 5.

This calculator helps you quickly compute these counts for larger values of n, and also supports practical restrictions such as limiting the largest part or forcing an exact number of parts.

How to use this partition calculator

  • Number to partition (n): the target integer (0 or greater).
  • Maximum allowed part: optionally cap the size of each summand.
  • Exact number of parts: optionally require exactly k summands.
  • Sample limit: choose how many example partitions you want listed.

If you leave optional fields blank, the tool computes the unrestricted partition count. This is the classical partition function, often written as p(n).

Quick example

Suppose n = 8, maximum part is blank, and exact number of parts is 3. The calculator returns the number of partitions of 8 using exactly three parts: 6+1+1, 5+2+1, 4+3+1, 4+2+2, and 3+3+2. Total: 5.

Why this matters

Partition counting appears in combinatorics, number theory, generating functions, and even physics. In practical problem solving, partition constraints are useful in:

  • Distribution and allocation problems
  • Enumerating combinations under bounded resources
  • Studying recurrence relations and dynamic programming
  • Teaching counting methods in discrete mathematics

Common partition variants

Unrestricted partitions

All positive parts are allowed, and any number of parts may be used. This gives p(n), the classical partition function.

Bounded largest part

Sometimes each summand must be less than or equal to a limit M. Set “Maximum allowed part” to enforce this directly.

Fixed number of parts

If a problem says “split n into exactly k groups,” use the exact-parts field. This returns only partitions with that part count.

Implementation note

The calculator uses a dynamic programming approach to compute exact counts efficiently, and it uses BigInt so large partition totals are handled accurately. Sample partition listings are generated separately and capped by your display limit for speed.

Final thoughts

Integer partitions are simple to define but surprisingly deep. Whether you are checking homework, building combinatorial intuition, or exploring advanced number theory ideas, this partition calculator gives quick, reliable results and transparent examples.

🔗 Related Calculators