Toolstia / Permutation and combination calculator
Permutation and combination calculator
Counting arrangements is one of the first places where numbers grow beyond intuition. Choose 5 cards from a 52-card deck and there are 2,598,960 possible hands. Arrange all 52 and the count has 68 digits. This calculator takes the total number of items n and the number you choose r, and returns two counts: permutations, where the order of the chosen items matters, and combinations, where it does not.
A tick box switches on repeats, for cases where the same item can be picked more than once, such as digits in a PIN or scoops of ice cream from a few flavours. The arithmetic uses arbitrary-size whole numbers, so results are exact all the way up to n and r of 5,000. They are never rounded to floating-point approximations, and a Copy button gives you every digit.
All of it runs in your browser, with nothing sent to a server. The sections below explain which count to use for a given question, show worked examples that you can reproduce, and describe the edge cases the tool handles.
Enter whole numbers from 0 to 5000 for n and r.
Example: choosing 3 people from 10 for a team (order does not matter) gives 120 combinations. Choosing a president, a secretary and a treasurer from 10 (order matters) gives 720 permutations.
How it works
- Enter n and r.
- Tick Allow repeats if an item can be chosen more than once.
- Read nPr and nCr, and copy the exact value if you need it.
Permutations
nPr = n! ÷ (n − r)!. It counts the ordered arrangements of r items chosen from n. Choosing a first, second and third place from 10 runners gives 720 possibilities.
Combinations
nCr = n! ÷ (r! × (n − r)!). It counts the groups of r items, ignoring order. Choosing 3 people from 10 for a team gives 120 groups. Each group can be arranged in r! ways, which is why nPr = nCr × r!.
With repeats
If items can be reused, the number of ordered choices is n^r, and the number of unordered choices is the combination of n + r − 1 items taken r at a time.
Big numbers
Values are calculated with exact big-integer arithmetic. Long results are shortened on screen, with the number of digits shown, and the Copy button gives you the full number.
Permutation or combination: a quick test
Ask whether swapping two chosen items gives a different outcome. If you pick a president, a secretary and a treasurer, giving the roles to the same three people in a different order is a different result, so use permutations. If you pick a committee of three people with no roles, the same three people in any order are one committee, so use combinations.
Choosing 3 from 10 gives 720 permutations and 120 combinations. The two are related: permutations equal combinations times r factorial, and 120 x 6 = 720, because each group of 3 can be ordered in 3! = 6 ways.
The formulas
Without repeats, the number of permutations of r items from n is n!/(n - r)!, which is n x (n - 1) x ... for r factors. The number of combinations is n!/(r! x (n - r)!). The tool multiplies and divides step by step with whole numbers rather than computing huge factorials, so it stays fast and exact.
With repeats allowed, permutations are n to the power r, because every position has n choices. Combinations with repeats use the 'stars and bars' result: C(n + r - 1, r). For example, choosing 3 scoops from 10 flavours, where order does not matter and repeats are fine, gives C(12, 3) = 220, while 4-digit PINs from the digits 0 to 9 give 10 to the 4th = 10,000 permutations with repeats.
More worked examples you can reproduce
Poker hands: 52 choose 5 is 2,598,960 combinations. Ordered five-card sequences from the same deck are 52P5 = 311,875,200, which is 2,598,960 x 120.
A lottery where you pick 6 numbers from 49: 49C6 = 13,983,816, so a single ticket has a 1 in 13,983,816 chance of matching all six. Four different letters chosen in order from the 26-letter alphabet: 26P4 = 358,800. Seating 10 people in a row, all of them: 10P10 = 3,628,800. Choosing 15 from 30: 30C15 = 155,117,520.
How big numbers are displayed
Numbers up to 60 digits are shown in full with thousands separators. Longer ones show the first 20 digits, an ellipsis and the last 10 digits, plus the total digit count, so you can still read the size of the answer. The Copy button next to each result copies the complete exact number as plain digits, ready for a spreadsheet or code.
To give a feel for scale: 100P100, the ways to order 100 distinct items, has 158 digits. 5000C2500 has 1,504 digits, and 5000P5000 has 16,326. With repeats, 5000 to the power 5000 has 18,495 digits. A scientific calculator would show these as overflow or a rounded exponent, but here you get every digit.
Edge cases
Choosing zero items has exactly one outcome, the empty selection, so r = 0 gives 1 for both counts. If r is larger than n and repeats are off, you cannot fill the places, so both counts are 0 and the tool tells you. With repeats on, r may exceed n: choosing 7 items from 5 types with repeats gives 330 combinations.
If n is 0, the only result is 1 for r = 0, and 0 for any positive r with repeats. n and r must be whole numbers from 0 to 5,000; decimals, negatives and blanks show a prompt instead of a result.
What it does not cover
The tool counts selections from distinct items. It does not count arrangements of items that repeat, such as the distinct orderings of the letters in MISSISSIPPI, which needs the multinomial formula (11! divided by 4!, 4! and 2!). It also does not handle circular seating, where rotations are the same arrangement, or constraints like 'these two must sit together'. For those, build the count from factorials by hand, or divide a permutation count by the number of identical arrangements.
Questions
What if r is bigger than n?
Without repeats the answer is 0, because you cannot choose more items than you have.
How large can n be?
Up to 5000.
Is anything uploaded?
No. Your numbers stays in your browser and is never sent anywhere.
Is a combination lock a combination or a permutation?
Mathematically it is a permutation, since the order of the digits matters. A 4-digit lock with digits 0 to 9 allows repeats, so the count is 10 to the power 4, or 10,000. Tick Allow repeats and read the permutation result.
What does 'Allow repeats' change?
It lets the same item be chosen more than once. Permutations then become n to the power r, and combinations become C(n + r - 1, r). Use it for PINs, dice sequences and choosing scoops from a limited set of flavours.
Why are the results exact when my calculator shows 1.2E+30?
Most calculators store numbers as floating-point values with about 15 significant digits. This tool uses whole-number arithmetic that grows as large as needed, so every digit is correct.
Why is nCr with r equal to 0 equal to 1?
There is exactly one way to choose nothing. This also follows from the formula, because 0! is defined as 1, so n!/(0! x n!) equals 1.