Permutations
P(n, r) = n! ÷ (n − r)!
There are n choices for the first position, n − 1 for the second, and so on. A four-digit code from digits 0–9 with no repeated digit has 10 × 9 × 8 × 7 = 5,040 possibilities if leading zero is allowed.
Counting and probability
Count selections and arrangements. Choose whether order matters and whether an item can be selected again.
Exact number of selections
Enter n and r, then select Calculate.
The full integer is shown above. Select it to copy using your keyboard or touch controls.
| Rule | Count |
|---|
Long comparison counts and recent-history entries use a preview with their digit count. The selected result above is always complete.
Calculations run in your browser. Successful results appear in this tab's Recent calculations.
P(n, r) = n! ÷ (n − r)!
There are n choices for the first position, n − 1 for the second, and so on. A four-digit code from digits 0–9 with no repeated digit has 10 × 9 × 8 × 7 = 5,040 possibilities if leading zero is allowed.
C(n, r) = n! ÷ [r! × (n − r)!]
Divide the ordered count by r!, the number of arrangements of each chosen group. Selecting three people from ten gives C(10, 3) = 120 groups.
Count = n^r
Every position has n choices. Four positions using digits 0–9 give 10⁴ = 10,000 codes when repetition and leading zero are allowed.
Count = C(n + r − 1, r)
For n ≥ 1, this counts nonnegative amounts of n types summing to r. Four scoops from three flavors, with unlimited supply of each flavor, give C(6, 4) = 15 flavor-count combinations.
Selecting nothing has exactly one outcome: the empty selection. Every mode returns 1 when r = 0, including n = 0. This is a counting convention, not a general rule for every expression involving 0⁰. If n = 0 and r is positive, the count is 0.
Without repetition, choosing more items than are available is impossible, so r > n returns 0. The calculator explains the zero instead of evaluating a factorial of a negative number. With repetition and at least one available type, r may exceed n. The factorial convention is 0! = 1.
Both n and r must be integers from 0 through 1,000, with at most 32 input characters per field. Surrounding whitespace and leading zeros are allowed; signs, commas, decimal points, and exponent notation are not. Every calculation uses exact whole numbers. Results are never rounded or converted to floating point.
The tool counts possibilities without generating a list of them. It assumes distinct available items or types and the stated repetition rule. It does not account for limited supplies of repeated types, forbidden positions, circular arrangements, or permutations of an existing collection with identical copies. A count is not a probability; probabilities also need an appropriate sample space and likelihood model.
References: OpenStax — Counting Principles, MIT Mathematics for Computer Science — counting with repetitions, and the zero-count conventions in Python's combinations and permutations documentation. Calculations here run in browser JavaScript; no Python service is involved.
Swap two chosen items. If that creates a different outcome, order matters. Swapping people in a committee changes nothing; swapping a president and a treasurer changes the assignment.
Here it means the same type may be selected repeatedly, with unlimited supply. Arranging the letters in a word with repeated letters is a different problem that requires the count of each letter.
There is one way to make an empty selection: select nothing. This boundary case keeps the counting rules consistent, even when no items are available.
Yes. For example, 1,000 choices at each of 1,000 positions gives 1000¹⁰⁰⁰, an integer with 3,001 digits. The selected result field contains every digit; comparison rows and recent history may use an explicitly shortened preview.