Przejdź do treści
Liczbnik
Current for 2026Methodology

Factorial, combinations and permutations calculator

Enter n and k, and the calculator instantly computes n! (factorial), C(n,k) (combinations) and P(n,k) (permutations). Useful for combinatorics, probability, statistics and exam problems. Supports values up to n = 170 within the precision of IEEE 754 floating-point arithmetic.

Na tej stronie

How we calculate factorials and combinations

Factorial: n! = 1 × 2 × … × n, with 0! = 1 by definition. Combinations: C(n,k) = n! / (k! × (n−k)!). Permutations: P(n,k) = n! / (n−k)!. An iterative algorithm minimises rounding errors for large n.

Example calculation

For n = 5 and k = 2: factorial 5! = 120; combinations C(5,2) = 10 (number of 2-element subsets of a 5-element set); permutations P(5,2) = 20 (ordered selections of 2 from 5).

Frequently asked questions

What is a factorial and how is it calculated?

The factorial of n (written n!) is the product of all integers from 1 to n. Example: 5! = 120. By definition 0! = 1.

What are combinations C(n,k)?

C(n,k) counts the ways to choose k items from n when order does not matter. Formula: C(n,k) = n! / (k! × (n−k)!). Example: C(5,2) = 10.

What are permutations P(n,k)?

P(n,k) counts ordered selections of k items from n. Formula: P(n,k) = n! / (n−k)!. Example: P(5,2) = 20.

Order matters in permutations but not in combinations. P(n,k) = C(n,k) × k!, so every combination can be arranged in k! ways.

JavaScript's number type (IEEE 754 double) gives exact results up to n = 170. For n = 171 the result exceeds the maximum finite value and becomes Infinity.

From the recurrence n! = n × (n−1)!: setting n = 1 gives 1! = 1 × 0!, so 0! = 1. It also represents the one way to arrange an empty set.

C(n,k) = 0 when k > n — you cannot choose more items than are available. The calculator returns 0 automatically.

The nth row of Pascal's triangle contains C(n,0), C(n,1), …, C(n,n). Each element is the sum of the two above it: C(n,k) = C(n−1,k−1) + C(n−1,k).

C(52,5) = 2,598,960. Enter n = 52 and k = 5 to verify instantly.

In probability (lottery, cards, dice), statistics (binomial coefficients), cryptography (key-space size), biology (gene combinations) and competitive math.

Results are indicative. For n > 170 the factorial exceeds the IEEE 754 range and returns Infinity.

  • GCD and LCM Calculator

    Calculate GCD (greatest common divisor) and LCM (least common multiple) of two numbers. Free online calculator.