HomeMath › Combinations and Permutations Calculator

Combinations and Permutations Calculator

Counts the ways to choose k items from n: combinations C(n, k) when order does not matter and permutations P(n, k) when it does, with or without repetition.

When to use

You need nCr (binomial coefficient), nPr, or the number of multisets or sequences of length k drawn from n items.

Do not use when: You need the probability of a specific outcome (use probability-of-events or binomial-distribution) or a plain factorial (use factorial).

Formula

Without repetition: C(n,k) = n! / (k! (n−k)!), P(n,k) = n! / (n−k)!. With repetition: C = (n+k−1)! / (k! (n−1)!), P = n^k

Computed with the multiplicative formula (no intermediate factorials) so that n can be large; results above 2^53 are correct to about 15 significant digits.

Inputs

ParameterTypeUnitRequiredDescription
nintegeryesSize of the set. Range: ≥ 0, ≤ 100000
kintegeryesNumber of items selected or arranged. Range: ≥ 0, ≤ 1000
with_repetitionbooleandefault falsetrue when an item may be chosen more than once (multisets / sequences with replacement).

Outputs

OutputTypeUnitDescription
combinationsnumberC(n, k) = n! / (k!(n − k)!), or C(n + k − 1, k) with repetition.
permutationsnumberP(n, k) = n! / (n − k)!, or n^k with repetition.
expressionstringThe formulas with the numbers filled in.

Example

Choose 3 of 10: {"n":10,"k":3,"with_repetition":false}{"combinations":120,"permutations":720,"expression":"C(10,3) = 120; P(10,3) = 720"}

Choose 2 of 5 with repetition: {"n":5,"k":2,"with_repetition":true}{"combinations":15,"permutations":25}

GET https://tttkmbb.com/api/v1/calculate/combinations-permutations?n=10&k=3&with_repetition=false

Machine access

Sources

FAQ

Combination or permutation?

Use combinations when only which items are chosen matters (lottery numbers, committees) and permutations when their order matters (rankings, passwords).

What happens when k > n without repetition?

There are no such selections, so both counts are 0.

Related calculators