Combinatorics

Count ordered or unordered selections, repeated choices and arrangements with exact integer arithmetic.

About this tool

Choose the counting question. n is the number of distinct items or symbols and r the selection size. Order matters for ordered selection; Allow repetition permits choosing a type more than once. The menu tooltip and optional Formula explain the model. Example loads five cards from 52 (2,598,960 choices) or a four-digit PIN from ten symbols (10,000 choices with repetition).

Small bounded requests update after a short typing pause. Calculate appears for larger work or long frequency lists; those requests run only on click or Enter in a number field. Changing inputs clears outdated output. Exact raw inputs, including incomplete or invalid counts, restore on reload; answers do not. Small restored requests recalculate automatically, larger ones wait for Calculate.

Without repetition: C(n,r)=n!/[r!(n−r)!] for unordered choices, P(n,r)=n!/(n−r)! for ordered choices. With repetition: C(n+r−1,r) for n>0 unordered types, n^r for ordered choices. An empty selection has one possibility, including n=r=0; no positive selection is possible from zero types, and r>n without repetition gives zero. Arrange all distinct items gives n!, with 0!=1.

Arrange repeated items accepts one non-negative frequency per type. The list 2,2,3 describes seven items and gives 7!/(2!2!3!)=210 arrangements. Commas, semicolons, spaces and newlines separate frequencies; zero frequencies are allowed. Formula includes the total item count.

Inputs and results use exact BigInt integers, including n above Number precision. Use decimal digits without separators, decimals or exponent notation. Limits remain: 1000 digits per count, 100,000 frequency characters, factorial/total frequencies up to 5000, up to 5000 selection factors and 50,000 output digits. A conservative estimate can reject near-limit output; it never changes a calculated integer. Live scheduling conservatively limits automatic work to about 200 factors and a 2000-digit upper estimate, and short frequency lists. All other supported work remains available explicitly.

Up to 200 result digits are shown in full with locale grouping. Larger results show the first 64 and last 32 digits, with the complete ungrouped integer in a bounded expandable area. Copy and TXT always contain all ungrouped digits. Clipboard errors are reported and old asynchronous feedback is ignored after edits or leaving. All computation stays in your browser.