Counting and probability

Combinations and Permutations Calculator

Count selections and arrangements. Choose whether order matters and whether an item can be selected again.

Count selections

Whole numbers from 0 to 1,000. n counts distinct items or types; r is the number of selections or positions. Enter 1000 without a comma.

For a team, AB and BA are the same. For assigned roles, AB and BA are different.

With repetition, each type has unlimited supply. Without repetition, each distinct item is used at most once.

Compare all four interpretations below.

Exact number of selections

Enter n and r, then select Calculate.

Calculations run in your browser. Successful results appear in this tab's Recent calculations.

The four counting formulas

Order matters · No repeats

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.

Order does not matter · No repeats

Combinations

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.

Order matters · Repeats allowed

Ordered selections with repetition

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.

Order does not matter · Repeats allowed

Combinations with repetition

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.

Zero, impossible selections, and exact counts

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.

Common questions

How do I tell whether order matters?

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.

Does repetition mean my original objects already contain duplicates?

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.

Why is choosing zero items equal to one?

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.

Can the result be thousands of digits long?

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.