Updated Combinatorics & Counting Tool

Combinatorics Calculator

Compute factorials, permutations, combinations, derangements, multinomial coefficients, stars and bars, Stirling numbers, Catalan numbers and Bell numbers in one place. Ideal for probability, discrete mathematics, contest problems and homework checks.

Permutations & Combinations Multisets & Repetition Derangements & Stirling Catalan & Bell Numbers

All-in-One Combinatorics & Counting Suite

This Combinatorics Calculator brings together the standard counting formulas from discrete mathematics: factorials, permutations, combinations, repetitions, derangements, multinomial coefficients, stars and bars, Stirling numbers, Catalan numbers and Bell numbers. Use the tabs to select the structure that matches your problem and get exact values where possible.

The factorial of a non-negative integer \(n\) is \[ n! = 1 \cdot 2 \cdot 3 \cdots n,\quad 0! = 1. \] The double factorial satisfies \[ n!! = n \cdot (n-2) \cdot (n-4) \cdots, \] with the conventions \(0!! = 1\) and \((-1)!! = 1\).

For permutations without repetition of \(r\) distinct objects chosen from \(n\) distinct objects, \[ P(n,r) = \frac{n!}{(n-r)!},\quad 0 \le r \le n. \] The number of linear permutations of all \(n\) objects is \(n!\), and the number of circular permutations is \((n-1)!\) when rotations are identified.

Combinations count selections where order does not matter. For \(r\) objects chosen from \(n\) distinct objects without repetition, \[ C(n,r) = \binom{n}{r} = \frac{n!}{r! (n-r)!},\quad 0 \le r \le n. \]

The number of ways to choose \(r\) objects from \(n\) distinct types with repetition allowed and order ignored (multiset combinations) is \[ C(n+r-1,r) = \binom{n+r-1}{r}. \]

For a multiset with \(n\) total objects and type counts \(a_1, a_2, \dots, a_k\) such that \(a_1 + a_2 + \dots + a_k = n\), the number of distinct permutations is \[ \frac{n!}{a_1! a_2! \cdots a_k!}. \]

A derangement of \(n\) distinct objects is a permutation with no fixed points. The number of derangements \(!n\) satisfies the recurrence \[ !0 = 1,\quad !1 = 0,\quad !n = (n-1)\bigl(!(n-1) + !(n-2)\bigr). \] It is also close to \(n!/e\) for large \(n\).

The multinomial coefficient counts ways to distribute \(n\) labeled objects into groups of sizes \(k_1,\dots,k_m\) where \(k_1 + \dots + k_m = n\): \[ \binom{n}{k_1,k_2,\dots,k_m} = \frac{n!}{k_1! k_2! \cdots k_m!}. \]

Stars and bars counts integer solutions to \[ x_1 + x_2 + \dots + x_k = n. \] With non-negative integers, the number of solutions is \[ \binom{n + k - 1}{k - 1}, \] and with positive integers it is \[ \binom{n - 1}{k - 1} \] provided \(n \ge k\).

Stirling numbers of the second kind \(S(n,k)\) count ways to partition an \(n\)-element set into \(k\) non-empty unlabeled subsets, with recurrence \[ S(n,k) = k S(n-1,k) + S(n-1,k-1). \] Unsigned Stirling numbers of the first kind \(c(n,k)\) count permutations of \(n\) elements with exactly \(k\) cycles, with recurrence \[ c(n,k) = c(n-1,k-1) + (n-1) c(n-1,k). \]

The \(n\)-th Catalan number \(C_n\) counts many structures such as valid parenthesizations and certain lattice paths. One closed form is \[ C_n = \frac{1}{n+1} \binom{2n}{n}. \] The \(n\)-th Bell number \(B_n\) counts partitions of an \(n\)-element set into any number of non-empty blocks.

Combinatorics Calculator – Complete Guide to Permutations, Combinations and Advanced Counting

The Combinatorics Calculator on MyTimeCalculator collects the most common counting functions used in discrete mathematics and probability. It helps you evaluate factorials, permutations, combinations, derangements, multinomial coefficients, stars and bars expressions, Stirling numbers, Catalan numbers and Bell numbers.

When solving counting problems, the main challenge is choosing the correct structure and formula. This calculator is organized into tabs that mirror how these structures appear in real problems so you can quickly match the situation and verify your results.

1. Factorials and Double Factorials

Factorials are the foundation of many counting formulas. For a non-negative integer \(n\),

\[ n! = 1 \cdot 2 \cdot 3 \cdots n,\quad 0! = 1. \]

The double factorial skips every other integer. For positive integers,

\[ n!! = n (n-2) (n-4) \cdots, \]

stopping at \(2\) or \(1\) depending on parity, with the conventions \(0!! = 1\) and \((-1)!! = 1\). Double factorials appear in formulas involving binomial coefficients, central moments and certain lattice path counts.

2. Permutations: Ordered Arrangements

Permutations count arrangements where order matters. The number of ways to arrange \(r\) distinct objects chosen from \(n\) distinct objects without repetition is

\[ P(n,r) = \frac{n!}{(n-r)!},\quad 0 \le r \le n. \]

When all \(n\) objects are used, there are \(n!\) linear permutations. If rotations are considered the same, circular permutations of \(n\) labeled objects are counted by \((n-1)!\). These formulas are standard in probability problems about ordering, seating arrangements and ranking.

3. Combinations: Unordered Selections

Combinations ignore order. The number of ways to choose \(r\) elements from \(n\) distinct elements without repetition is

\[ C(n,r) = \binom{n}{r} = \frac{n!}{r!(n-r)!}. \]

This function is symmetric in \(r\) and \(n-r\) and appears in binomial expansions, probability of drawing subsets and many discrete distributions. The calculator also provides combinations with repetition, which correspond to multisets of size \(r\) drawn from \(n\) types.

4. Multisets, Repetition and Multinomial Coefficients

When repetition is allowed and order is ignored, the number of combinations of size \(r\) from \(n\) types is

\[ \binom{n+r-1}{r}, \]

often derived using the stars and bars method. For permutations with repeated items, the relevant count is the number of distinct arrangements of a multiset with type counts \(a_1,\dots,a_k\):

\[ \frac{n!}{a_1! a_2! \cdots a_k!}, \quad n = a_1 + \dots + a_k. \]

The same denominator appears in the multinomial coefficient, which generalizes the binomial coefficient to partitions of a set into more than two labeled groups.

5. Derangements and the Probability of No Fixed Points

A derangement of \(n\) objects is a permutation with no fixed points: no item ends up in its original position. The number of derangements \(!n\) satisfies the recurrence

\[ !0 = 1,\quad !1 = 0,\quad !n = (n-1)\bigl(!(n-1) + !(n-2)\bigr). \]

A well-known approximation is \(!n \approx n!/e\), so the probability that a random permutation of \(n\) elements has no fixed point is close to \(1/e\) for large \(n\). The calculator reports both the exact value (for moderate \(n\)) and this approximation.

6. Stars and Bars: Integer Solutions to Sum Constraints

Many distribution problems ask for the number of integer solutions to

\[ x_1 + x_2 + \dots + x_k = n \]

subject to constraints such as \(x_i \ge 0\) or \(x_i \ge 1\). Stars and bars transforms this into a combinatorial selection problem:

  • For non-negative integers \(x_i \ge 0\), there are \(\binom{n + k - 1}{k - 1}\) solutions.
  • For positive integers \(x_i \ge 1\), there are \(\binom{n - 1}{k - 1}\) solutions provided \(n \ge k\).

These counts appear in questions about distributing identical balls into boxes, allocating units of resource or counting coefficient patterns in algebraic expansions.

7. Stirling Numbers, Catalan Numbers and Bell Numbers

Stirling numbers and related sequences capture deeper structure in permutations and set partitions.

  • Stirling numbers of the second kind \(S(n,k)\) count partitions of an \(n\)-element set into \(k\) non-empty unlabeled blocks, satisfying \[ S(n,k) = k S(n-1,k) + S(n-1,k-1). \]
  • Unsigned Stirling numbers of the first kind \(c(n,k)\) count permutations of \(n\) elements with exactly \(k\) cycles, with recurrence \[ c(n,k) = c(n-1,k-1) + (n-1) c(n-1,k). \]

The Catalan numbers \(C_n\) appear in many balanced structure counts, including valid parenthesizations, certain lattice paths and full binary trees. A standard closed form is

\[ C_n = \frac{1}{n+1}\binom{2n}{n}. \]

The Bell numbers \(B_n\) count partitions of an \(n\)-element set into any number of non-empty blocks. They can be expressed in terms of Stirling numbers of the second kind as

\[ B_n = \sum_{k=1}^n S(n,k). \]

These sequences grow quickly, so the calculator restricts \(n\) to moderate values and focuses on exact integer results that are still numerically stable.

Related Tools from MyTimeCalculator

Combinatorics Calculator FAQs

Frequently Asked Questions

Quick answers to common questions about permutations, combinations, repetition, derangements, Stirling numbers and other combinatorial quantities in this calculator.

Use permutations when order matters and combinations when order does not matter. For example, arranging people in seats is a permutation problem, while choosing a committee of people regardless of their roles is a combination problem. The calculator separates these into different tabs so you can pick the correct structure before entering your values.

Factorials and related sequences grow extremely quickly. Beyond certain sizes, values exceed the range of standard floating-point arithmetic or lose integer precision. The calculator restricts n to ranges where results remain numerically stable and meaningful, and it switches to approximate descriptions once exact values are no longer practical to display in a browser environment.

Yes. Many probability formulas, especially in discrete settings, are built from factorials, permutations, combinations and multinomial coefficients. You can use the calculator to obtain these counts and then plug them into probability formulas, such as those for binomial, hypergeometric or multinomial distributions, while keeping track of the denominators manually in your work.

Stirling numbers of the second kind \(S(n,k)\) count partitions of an n-element set into exactly k non-empty unlabeled blocks. Bell numbers \(B_n\), by contrast, count partitions into any number of blocks and can be obtained by summing \(S(n,k)\) over all possible k. Stirling numbers of the first kind relate to cycles in permutations rather than set partitions.

The calculator is well suited to checking numeric answers for combinatorics questions from contests, exams or homework. You still need to set up the correct model and justify your reasoning, but once you have identified the right formula, this tool can confirm that your final numerical value matches the expected count or highlight possible arithmetic mistakes.