# Combination & Permutation Calculator

- **URL:** https://codeasystem.com/calculators/statistics/combination-permutation-calculator/
- **Category:** statistics
- **Description:** Compute C(n,r) combinations and P(n,r) permutations together, with exact loop-product arithmetic for large n.
- **Primary output:** Combinations C(52, 5): 2,598,960

## Inputs
- Total items (n) (name: `n`, type: number, example: 52)
- Chosen items (r) (name: `r`, type: number, example: 5)

## Outputs
- Combinations C(52, 5): 2,598,960
- Permutations P(52, 5): 311,875,200
- Order matters?: Combinations ignore order; permutations count every ordering separately.

## Formula / methodology
```
C(n,r) = n! / (r!(n−r)!)   P(n,r) = n! / (n−r)!
```

Combinations count unordered selections; permutations count ordered arrangements; same items, r! times as many results. Both are computed via running products rather than literal factorials, so intermediate values stay small and exact even for huge n where n! would overflow IEEE doubles (beyond 170!).

Validation enforces non-negative whole numbers with r ≤ n. Edge cases behave sensibly: choosing everything or nothing yields exactly one combination.

## Assumptions & limitations
- n and r must be non-negative integers.
- Items are distinct; no repetition allowed within a selection.
- Order distinguishes permutations from combinations.

## How to use
1. **Set n and r**; n is how many items exist; r is how many you pick.
2. **Read both answers**; The main number is C(n,r); the permutation row gives P(n,r) for ordered scenarios.
3. **Choose which applies**; Lotteries, committees and hands are combinations; rankings, passwords and race finishes are permutations.

## Example
A 5-card poker hand from a 52-card deck: 2,598,960 combinations; but 311,875,200 permutations once card order is considered.

Result for these inputs:

```
Combinations C(52, 5): 2,598,960
```

## About this calculator
### Combinations or permutations?

Ask one question: would swapping two chosen items create a new outcome? A poker hand stays the same hand when reordered; combination. A podium finish changes meaning when gold and silver swap; permutation.

### Why no factorial blowups

Directly computing 1000! overflows any floating-point format. Multiplying r ratios one at a time keeps every partial product a modest integer, which is why C(1000,3) computes instantly and exactly here.

- C(n,0) = C(n,n) = 1 always.
- P(n,r) = C(n,r) × r!
- r > n is rejected as impossible.

## FAQs
### What if order does not matter but repeats are allowed?

That is combinations with repetition: C(n+r−1, r); compute it here by substituting those adjusted arguments.

### How large can n be?

Very large; the loop-product method avoids factorial overflow entirely. Only astronomically large exact results exceed floating-point integer precision beyond 2⁵³.

### Why does r ≤ n matter?

You cannot choose more distinct items than exist; requesting r > n has no mathematical answer and returns an error.

### Is C(n,r) always an integer?

Yes; it counts selections. The incremental division in the loop product preserves this exactly.

## Related calculators
- [Probability Calculator (P(A∪B))](https://codeasystem.com/calculators/statistics/probability-calculator/)
- [Factorial Calculator](https://codeasystem.com/calculators/math/factorial-calculator/)
- [Random Number Generator](https://codeasystem.com/calculators/math/random-number-generator/)

---
Last updated: 2026-08-23 · Version: 1.0.0 · [HTML version](https://codeasystem.com/calculators/statistics/combination-permutation-calculator/)
