# Birthday Problem Calculator

> Computes the probability that at least two of n people share a birthday in a year of a given length (365 days by default), the complementary probability that all birthdays differ, the expected number of matching pairs, and the group sizes at which the chance reaches 50 % and 99 %.

- Calculator id: `birthday-problem` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_birthday_problem_probability`
- Canonical page: https://tttkmbb.com/statistics/birthday-problem · This document: https://tttkmbb.com/statistics/birthday-problem.md · JSON definition: https://tttkmbb.com/statistics/birthday-problem.json

## Purpose

Computes the probability that at least two of n people share a birthday in a year of a given length (365 days by default), the complementary probability that all birthdays differ, the expected number of matching pairs, and the group sizes at which the chance reaches 50 % and 99 %.

**Use when:** You want the classic birthday-paradox probability for a group, or the same collision probability for any set of equally likely categories (hash values, PINs, tokens).

**Do not use when:** You want the probability that someone shares a specific person's birthday (that is 1 − (364/365)^(n−1), a different question), or birthdays are far from uniform.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `people` | integer |  | required | Size of the group. (min 1, max 100000) |
| `days` | integer |  | optional, default 365 | Number of equally likely birthdays or categories (365 ignores leap days; use 366 to include them). (min 1, max 1000000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `probability_shared` | number |  | 1 − P(all different). |
| `probability_shared_percent` | number | % | Same probability in percent. |
| `probability_all_different` | number |  | Π_{i=0}^{n−1} (1 − i/days). |
| `expected_matching_pairs` | number |  | C(n, 2) / days: expected number of pairs sharing a birthday. |
| `people_for_50_percent` | integer |  | Smallest group with at least a 50 % chance of a shared birthday. |
| `people_for_99_percent` | integer |  | Smallest group with at least a 99 % chance. |

## Formula

`P(all different) = Π_{i=0}^{people−1} (1 − i/days) = days! / ((days − people)! · days^people); P(shared) = 1 − P(all different); expected pairs = people·(people − 1) / (2·days)`

Assumes birthdays are independent and uniformly distributed over the days. With more people than days the probability is exactly 1 (pigeonhole principle). Real birthdays are slightly non-uniform, which raises the probability marginally.

## Data Sources

- Wikipedia – Birthday problem — https://en.wikipedia.org/wiki/Birthday_problem (reference, retrieved 2026-09-24)
- Wolfram MathWorld – Birthday Problem — https://mathworld.wolfram.com/BirthdayProblem.html (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/birthday-problem?people=…`
- `POST https://tttkmbb.com/api/v1/calculate/birthday-problem` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/birthday-problem · OpenAPI operationId `calculate_birthday_problem_probability` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "birthday-problem", "inputs": {…}}`

## Example

- 23 people: inputs `{"people":23}` → `{"probability_shared":0.507297,"probability_shared_percent":50.73,"probability_all_different":0.492703,"expected_matching_pairs":0.6932,"people_for_50_percent":23,"people_for_99_percent":57}`
- 30 people: inputs `{"people":30,"days":365}` → `{"probability_shared":0.706316,"probability_shared_percent":70.63,"expected_matching_pairs":1.1918}`

```
GET https://tttkmbb.com/api/v1/calculate/birthday-problem?people=23
```

## Limitations

You want the probability that someone shares a specific person's birthday (that is 1 − (364/365)^(n−1), a different question), or birthdays are far from uniform. Assumes birthdays are independent and uniformly distributed over the days. With more people than days the probability is exactly 1 (pigeonhole principle). Real birthdays are slightly non-uniform, which raises the probability marginally. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why only 23 people for a 50 % chance?**

There are C(23, 2) = 253 pairs of people, and each pair has a 1/365 chance of matching; it is the number of pairs, not the number of people, that grows quickly.

**What about leap years?**

Set days = 366 to include 29 February as an equally likely day; the effect on the probability is tiny (50.63 % instead of 50.73 % for 23 people).

## Related

- [Probability of Two Events Calculator](https://tttkmbb.com/statistics/probability-of-events.md) — Combine probabilities of two events.
- [Combinations and Permutations Calculator](https://tttkmbb.com/math/combinations-permutations.md) — Count the pairs C(n, 2) behind the paradox.
