Permutation and Combination Calculator
Counts permutations and combinations of r items chosen from n. Without repetition it evaluates nPr = n!/(n−r)! and nCr = n!/(r!(n−r)!); with repetition allowed it returns n^r arrangements and C(n+r−1, r) selections. Results are computed with exact integer arithmetic rather than factorials, so n up to 500 produces every digit, and the formula used is displayed alongside both counts.
Enter how many items you have in total and how many of them you are choosing, and the calculator returns two counts at once: permutations, where the order of the chosen items matters, and combinations, where it does not. A third line shows the exact formula that produced the numbers, so the result can be checked or copied into written work. Both counts are computed with exact integer arithmetic rather than rounded floating point, which means the answer is correct to the last digit even when it runs to hundreds of digits. Tick the repetition box when the same item may be chosen more than once, as with digits in a PIN or scoops of ice cream, and both formulas switch accordingly.
How the two counts are calculated
Without repetition, the number of ordered arrangements of r items drawn from n is the falling product that starts at n and takes r steps down: the first pick has n options, the second has n − 1, and so on. Written with factorials it is:
nPr = n! ÷ (n − r)!
A combination ignores order, and any group of r items can be ordered in r! different ways, so the permutation count overstates the selection count by exactly that factor:
nCr = n! ÷ (r! × (n − r)!)
With repetition allowed, every one of the r positions can hold any of the n items, so ordered arrangements are simply n multiplied by itself r times. Unordered selections with repetition follow a less obvious rule, but it reduces to an ordinary combination on shifted inputs:
arrangements = nr and selections = C(n + r − 1, r)
The calculator never evaluates the giant factorials in these expressions directly. For the permutation it multiplies only the r factors that survive the cancellation, and for the combination it multiplies and divides alternately, one factor at a time, so that every intermediate value is a whole number and nothing is ever rounded. That is why the results stay exact where a factorial-based approach on ordinary floating point would silently lose digits beyond roughly 15 to 17 significant figures.
A worked example, from defaults to a deck of cards
The default inputs make the difference between the two counts concrete. Choosing 3 items from 10 without repetition, the ordered count is 10 × 9 × 8 = 720, because the first slot has ten candidates, the second nine and the third eight. Each group of three chosen items appears in that total 3! = 6 times, once per ordering, so the number of distinct groups is 720 ÷ 6 = 120. The formula line reads 10!/(10-3)! and 10!/(3!·7!), which is the factorial notation for the same arithmetic.
Card games supply the classic larger case. A 5-card hand from a standard 52-card deck is an unordered selection, so the count is 52 choose 5. The falling product is 52 × 51 × 50 × 49 × 48 = 311,875,200 ordered deals, and dividing by 5! = 120 gives 2,598,960 distinct hands. Enter 52 and 5 above and both figures appear directly: the permutation line shows the ordered deals and the combination line the hands. Every probability quoted for poker rests on that denominator, since the chance of any category of hand is the number of hands in the category divided by 2,598,960. A 6-of-49 lottery is the same calculation with different numbers: 49 choose 6 gives 13,983,816 possible tickets.
With the repetition box ticked and the defaults restored, the counts change character. Ten items chosen three at a time with reuse allowed give 10 × 10 × 10 = 1,000 arrangements, the familiar count of three-digit codes, and C(12, 3) = 220 unordered selections, worked as 12 × 11 × 10 ÷ 6.
Where the formulas came from
Counting arrangements is one of the oldest recorded mathematical activities, and its early history runs through prosody and language rather than gambling. The Chandahsastra of the Indian scholar Pingala, a treatise on Sanskrit verse metres traditionally dated to the 3rd or 2nd century BCE, though some scholarship places it nearer the start of the Common Era, gives a recursive procedure that enumerates every pattern of light (laghu) and heavy (guru) syllables a verse of n syllables can take. The enumeration corresponds mathematically to listing all 2^n binary sequences of that length, long before Leibniz's account of binary arithmetic, though Pingala was cataloguing verse patterns rather than calculating with binary numerals. The triangular table of binomial numbers often loosely associated with his name does not appear in his own text: it belongs to his tenth-century commentator Halayudha, whose Mrtasanjivani commentary laid the counts out as the meru-prastara, the staircase arrangement now known in the West as Pascal's triangle.
Combinatorial thinking also grew out of work on words. The Arab philologist and cryptographer al-Khalil ibn Ahmad (717–786) is credited with the first use of permutations and combinations, applied in his Book of Cryptographic Messages to list every possible Arabic word with and without vowels. The earliest known statement of the general rule for the number of combinations appears in the Ganita Sara Sangraha, written by the Indian mathematician Mahavira around 850 AD: multiply the r numbers counting down from n, then divide by the product of 1 through r. Bhaskara II's Lilavati of 1150 states the companion rule that n objects can be ordered in the product of the numbers 1 through n ways, the quantity now written n!. The binomial triangle itself kept surfacing: the Persian mathematician al-Karaji (953–1029) is credited with an explicit description of it in a book now lost, Omar Khayyam discussed it in another lost work cited in his algebra, and in eleventh-century China Jia Xian had the array, which Yang Hui credited to him in 1261 and which Chinese texts call Yang Hui's triangle.
The subject changed direction in the summer of 1654, when Blaise Pascal and Pierre de Fermat exchanged five letters on gambling problems put to Pascal by the Chevalier de Méré, above all the problem of points: how to divide the stakes of an interrupted game fairly. The problem was older, already studied by Italian writers, but counting the equally likely ways the game could have continued was the machinery of the 1654 answer, and the correspondence is conventionally taken as the foundation of the mathematical theory of probability. Pascal's Traité du triangle arithmétique, published posthumously in 1665, gave the triangle its European name, though he was not the first to study it. Jacob Bernoulli's Ars Conjectandi, unfinished at his death and published in Basel in 1713, eight years later, then gathered permutations, combinations and their repetition-allowed variants into a systematic treatment and bound them permanently to the mathematics of chance.
Why the counts grow so fast
Factorial growth outruns intuition almost immediately. Ten items can be fully ordered in 10! = 3,628,800 ways; doubling to twenty items raises that to roughly 2.4 quintillion, a 19-digit number. A shuffled 52-card deck has 52! possible orders, a 68-digit count, and at this calculator's ceiling 500! runs to 1,135 digits. The practical consequence is that enumerating arrangements one by one stops being feasible for even modest inputs, and the closed-form counts here are the only way to reason about them.
Choosing the repetition setting
Leave repetition off when each item can be used at most once: dealing cards, drawing lottery balls, seating people, or forming a committee. Turn it on when every choice draws from the full menu again: a 4-digit PIN allows 10^4 = 10,000 codes because each digit may repeat, and three dice show 6^3 = 216 ordered outcomes. The repetition-allowed combination answers stocking questions, where only how many of each kind matters. A box of a dozen doughnuts filled from eight varieties can be assembled in C(8 + 12 − 1, 12) = C(19, 12) = 50,388 distinct ways, a case where r exceeds n and the calculation is still perfectly meaningful. Without repetition that situation is impossible, since each pick removes an item, and the calculator reports it as an error rather than returning zero.
Assumptions and conventions
The calculator follows the standard convention that 0! = 1, so choosing zero items always yields exactly one result, the empty selection, and both counts read 1 when r is 0. Setting both n and r to 0 likewise returns 1 in every mode. With repetition enabled and n equal to 0, any positive r gives 0, since there is nothing to choose from. Inputs must be whole numbers from 0 to 500; fractional or negative entries produce an error message rather than a rounded guess, and without repetition r may not exceed n. All arithmetic is performed on exact integers, results are displayed in full with thousands separators, and nothing is ever rounded, truncated or shown in scientific notation, however long the number becomes.
Frequently asked questions
What is the difference between a permutation and a combination?
A permutation counts ordered arrangements and a combination counts unordered selections. Picking 3 items from 10 gives 720 permutations, because the 10 × 9 × 8 possible orderings are all distinct, but only 120 combinations, because each group of three can be ordered 6 ways and all 6 orderings count as the same selection.
How do you calculate nCr by hand?
Multiply r numbers counting down from n and divide by r factorial. For 52 choose 5, compute 52 × 51 × 50 × 49 × 48 = 311,875,200 and divide by 5! = 120 to get 2,598,960. Dividing after each multiplication instead of at the end keeps the intermediate numbers smaller and always lands on a whole number.
What changes when repetition is allowed?
Each of the r choices can reuse any of the n items, so ordered arrangements become n raised to the power r and unordered selections become C(n+r−1, r). With 10 items chosen 3 at a time that means 1,000 arrangements and 220 selections, against 720 and 120 without repetition.
Can r be bigger than n?
Only when repetition is allowed. Without repetition every pick removes one item from the pool, so at most n picks are possible and the calculator reports an error when r exceeds n. With repetition items return to the pool after each pick, so any r works: 3 symbols chosen 5 at a time give 3^5 = 243 arrangements.
How many 5-card hands can be dealt from a 52-card deck?
2,598,960. A hand is an unordered selection, so the count is 52 choose 5. The same deal counted as ordered sequences gives 311,875,200 permutations, which is exactly 120 times larger because each hand of five cards can be dealt in 5! = 120 different orders.
Why do the inputs stop at 500?
The counts grow explosively: 500 items can be arranged in 500! ways, a number 1,135 digits long, and this calculator computes and displays every one of those digits exactly. Capping n and r at 500 keeps the exact arithmetic instant while covering far larger cases than any practical counting problem needs.