Przejdź do treści
Liczbnik

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.

Reviewed byRedakcja Liczbnik
Calculator
ResultFactorial n!120
Combinations C(n,k)
10
Permutations P(n,k)
20

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.

What is the difference between combinations and permutations?

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

How does the calculator handle large factorials?

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.

Why is 0! = 1?

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.

Indicative result

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.

    Maths