Combinations and Permutations Calculator: nCr and nPr
By HesaplayıcıHow we calculate
The combinations and permutations calculator finds the exact integer number of ways to choose or arrange r items from n distinct options. Select whether order matters and whether repetition is allowed, then enter n and r to view the exact count, digit length and factorial breakdown.
Worked example: How many teams of 3 can be chosen from 10 people?
Number of ways
120
- Number of digits
- 3
Step by step
n! = 1 × 2 × … × n
10! = 1 × 2 × … × 10 = 3,628,800
r! = 1 × 2 × … × r
3! = 1 × 2 × 3 = 6
(n − r)! = 1 × 2 × … × (n − r)
7! = 1 × 2 × … × 7 = 5,040
Number of ways
C(n, r) = n! / (r! × (n − r)!)
C(10, 3) = 3,628,800 / (6 × 5,040) = 120
Factorials, combinations and permutations
A factorial (n!) is the product of all positive integers from 1 to n (5! = 120, 0! = 1). A combination counts unordered selections (teams, hands, committees); a permutation counts ordered arrangements (rankings, passcodes, officer roles). Pick the right mode with two questions: does order matter? and can an item be chosen more than once?
| Counting mode | Order matters? | Repetition? | Formula |
|---|---|---|---|
Combination (nCr) | No | No | C(n, r) = n! / (r! × (n − r)!) |
Permutation (nPr) | Yes | No | P(n, r) = n! / (n − r)! = C(n, r) × r! |
| Combination with repetition | No | Yes | C(n + r − 1, r) = (n + r − 1)! / (r! × (n − 1)!) |
| Permutation with repetition | Yes | Yes | nʳ |
Because every r-item combination can be ordered in r! ways, permutations without repetition always satisfy P(n, r) = C(n, r) × r!.
Worked examples across all four modes
- Combination without repetition — 3-person team from 10: Order does not matter (
A-B-CequalsC-B-A).C(10, 3) = 10! / (3! × 7!) = (10 × 9 × 8) / 6 = 120. - Permutation without repetition — president, VP and secretary from 10: Order matters.
P(10, 3) = 10 × 9 × 8 = 720(120 × 3!). - Combination with repetition — 3 pastries from 4 flavors: Flavors may repeat and bag order does not matter.
C(4 + 3 − 1, 3) = C(6, 3) = 20. - Permutation with repetition — 4-digit numeric PIN (
0–9): Digits may repeat and order matters.10⁴ = 10,000.
Limits
Accepts integers n from 1 to 1,000 and r from 0 to 1,000 (r ≤ n when repetition is off) using exact arbitrary-precision integer arithmetic. Results up to 21 digits display in full; longer counts display the first 10 significant digits in scientific notation on screen while API and MCP return every digit. Probability distributions, circular permutations and multiset anagrams (like MISSISSIPPI) are outside scope; for divisibility and prime factors see the GCD and LCM calculator.
Frequently Asked Questions
What is the difference between a combination and a permutation?
Order does not matter in a combination, whereas order does matter in a permutation. Picking a 3-person committee from 10 people gives C(10, 3) = 120 combinations; assigning president, vice president and secretary from the same 10 gives P(10, 3) = 720 permutations.
When should I allow repetition?
Allow repetition when the same item can be picked more than once. A 4-digit PIN using digits 0–9 (order matters) has 10⁴ = 10,000 permutations with repetition; buying 3 pastries from 4 flavors (order does not matter) has C(6, 3) = 20 combinations with repetition.
Can r be larger than n?
Not without repetition—you cannot pick 6 distinct items from 5. With repetition it is allowed: picking 6 candies from 3 flavors gives C(3 + 6 − 1, 6) = 28.
Why does 0! equal 1?
There is exactly one way to arrange zero items (the empty arrangement). Defining 0! = 1 keeps boundary cases like C(n, 0) = C(n, n) = 1 consistent.
Calculation rules
- In a combination the order does not matter: {A, B} and {B, A} are the same choice. In a permutation the order matters. With repetition, an item can be chosen more than once.
- The result is exact and never rounded. Up to 21 digits it is written in full; a longer result shows its first 10 significant digits and a power of 10 (for example 2.702882409 × 10²⁹⁹). The API and MCP give every digit.
- 0! is 1, so C(n, 0) = C(n, n) = 1 and P(n, 0) = 1. Without repetition, an r larger than n gives an error.