liminfo

Combinatorics Calculator

Free web tool: Combinatorics Calculator

About Combinatorics Calculator

The Combinatorics Calculator is a free online tool that computes six types of combinatorial quantities: permutations (nPr), combinations (nCr), factorials (n!), multi-permutations (n^r), multi-combinations H(n,r), and Catalan numbers. Select the calculation type, enter n (and r where required), click Calculate, and the result is displayed along with the formula used — for example, "P(5, 3) = 5! / (5-3)!" with the numerical answer "60".

Students, teachers, and mathematicians use this calculator for probability problems, discrete mathematics coursework, counting problems in algorithm analysis, and competition mathematics. The tool handles very large numbers accurately using JavaScript BigInt arithmetic, which avoids floating-point overflow that would occur with standard Number types for large factorials or combinations. Results exceeding 10 digits display a digit count to indicate magnitude.

The six supported calculation types cover the full range of elementary combinatorics: permutations count ordered arrangements without repetition, combinations count unordered subsets, factorials compute n!, multi-permutations count ordered selections with repetition (n^r), multi-combinations count multisets H(n,r) = C(n+r-1, r), and Catalan numbers compute C_n = C(2n,n)/(n+1) used in tree counting, bracket problems, and Dyck paths. Factorial input is capped at n=1000 and Catalan numbers at n=500 to prevent browser hangs.

Key Features

  • Six calculation types: permutation nPr, combination nCr, factorial n!, multi-permutation, multi-combination H(n,r), and Catalan number
  • BigInt arithmetic for exact integer results on arbitrarily large numbers without floating-point errors
  • Formula display alongside each result (e.g., "C(10, 3) = 10! / (3! * (10-3)!)")
  • Digit count display for results with more than 10 digits to show magnitude
  • Input validation with specific error messages (e.g., "r must be less than or equal to n")
  • One-click copy button to copy the numerical result to clipboard
  • Factorial capped at n=1000 and Catalan at n=500 to prevent performance issues
  • 100% client-side computation — all BigInt calculations run in the browser with no server calls

Frequently Asked Questions

What is the difference between permutation and combination?

A permutation nPr counts the number of ways to arrange r items chosen from n distinct items where order matters. A combination nCr counts the number of ways to choose r items from n distinct items where order does not matter. For example, P(4,2) = 12 (ordered pairs) while C(4,2) = 6 (unordered pairs).

What is a multi-permutation?

A multi-permutation (also called permutation with repetition) counts the number of ordered sequences of length r drawn from a set of n items where items can be repeated. The formula is n^r. For example, the number of 3-digit PINs using digits 0-9 is 10^3 = 1000.

What is a multi-combination H(n, r)?

A multi-combination (multiset combination) counts the number of ways to choose r items from n types where repetition is allowed and order does not matter. The formula is H(n,r) = C(n+r-1, r). For example, the number of ways to choose 3 fruits from 4 types (with repetition) is H(4,3) = C(6,3) = 20.

What are Catalan numbers used for?

Catalan numbers appear in many combinatorial counting problems: the number of valid bracket sequences of length 2n, the number of distinct binary trees with n+1 leaves, the number of ways to triangulate a convex polygon, and the number of Dyck paths from (0,0) to (2n,0). C_n = C(2n,n) / (n+1).

Why does the calculator use BigInt?

Standard JavaScript numbers are 64-bit floating-point (IEEE 754), which can only represent integers exactly up to 2^53 ≈ 9 quadrillion. Factorials and combinations grow much faster — for example, 21! exceeds 2^53. This calculator uses JavaScript BigInt, which supports exact arbitrary-precision integers, so results like 100! or C(200, 100) are computed and displayed with full precision.

What is the maximum value of n I can enter?

For factorials, n is capped at 1000 to prevent the browser from freezing. For Catalan numbers, n is capped at 500. For permutations, combinations, multi-permutations, and multi-combinations, there is no hard cap, but very large values of n or r may produce results with thousands of digits and could be slow to display.

How is the combination formula optimized?

The combination C(n, r) is computed using the optimization r = min(r, n-r) to reduce the number of multiplications. The result is computed iteratively as a running product rather than computing the full factorials n!, r!, and (n-r)! separately, which is faster and avoids intermediate overflow even with BigInt.

Is this calculator free?

Yes, completely free. No sign-up, no limits, and no ads that obstruct usage. All calculations happen locally in your browser with BigInt arithmetic.