ForHosting KIT · Math

Birthday paradox calculator

In a group of just 23 people, the chance that two share a birthday is already about 50 percent, even with 365 days in the year. Enter the group size and the number of days to get the exact shared-day probability. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
N
23
Number of possible days
365
You get
Probability
0.5072972343
All distinct
0.4927027657

The birthday paradox is the surprising fact that in a group of only twenty-three people, the chance that at least two share a birthday is already about fifty percent, even though a year has three hundred sixty-five days. The same math applies to any collision problem: hash buckets, meeting slots, random codes, or custom calendars with d possible labels. This calculator takes the group size n and the number of days d, multiplies the complementary product that all birthdays are distinct, and returns one minus that value as a stable decimal probability. Values of n or d below one are rejected with a clear validation error so incomplete or nonsense inputs never produce a silent false certainty. Results are fully deterministic arithmetic with no sampling and no language model.

What the birthday paradox measures and why it surprises people

Most people estimate shared-birthday risk by comparing the group size to the length of the year. That intuition looks for a match with one fixed person, so it underestimates collisions badly. The correct question is whether any pair among the group collides.

With n people there are n choose two pairs, and each pair has a small chance of matching on one of d days. Those pair events are not independent, so the clean closed form works with the complement instead: start from the probability that every person lands on a still-unused day, then subtract from one. Formally, fix an arbitrary ordering of the group.

The first person may have any day. The second must avoid the first person's day, which succeeds with probability (d minus one) over d. The third must avoid both previous days when they were distinct, and so on.

Multiplying those successive terms yields P(all distinct). One minus that product is P(at least one shared day). For the familiar calendar with d equal to three hundred sixty-five and n equal to twenty-three, the product falls just below one half, so the shared-day probability crosses fifty percent.

At n equal to fifty-seven the figure is already above ninety-nine percent. The same formula works for leap-year models with three hundred sixty-six days, short work weeks with seven slots, or synthetic label spaces such as four-digit PIN prefixes. Understanding the complement product is enough to demystify the paradox without Monte Carlo noise or tables of pair combinations.

Hash and ID collision intuition

Engineers illustrate approximate birthday bounds for short codes, cache keys, or bucket labels by setting d to the label space size and sweeping n until the shared probability becomes unacceptable.

Deterministic oracles for tests and tools

Interview platforms, quiz apps, and CI suites call a stable oracle that rejects n or d below one and returns identical probability fields for identical inputs.

What happens if n or d is below 1?

At least one person and at least one day label are required; zero and negative values are rejected and not charged.

Why is the chance already about 50% at 23 people?

The calculator multiplies the chance that each new person avoids all previous birthdays among 365 days.

Is the birthday paradox calculator free?

The browser tool runs free on your device.

Does this use simulation or random sampling?

No. It evaluates the closed complement product in deterministic floating arithmetic (log space for stability). The same n and d always return the same probability with no Monte Carlo noise.

Can I use a different number of days?

Yes. The number of days can be any whole number from 1 up to 1000000, so the same formula works for a leap-year model, 7 weekday slots, meeting times or random codes where you want the chance of a collision.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/prob/birthday-paradox

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/prob/birthday-paradox \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":23,"d":365}'
{
  "n": 23,
  "d": 365
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "prob.birthday_paradox",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_n100000
max_d1000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How this calculator validates input and evaluates the product

Call the capability with two required integers: n, the number of people, and d, the number of possible days or distinct labels. The engine checks that both values are finite integers inside the published limits: n from one through one hundred thousand, and d from one through one million. Log-space multiplication keeps intermediate products away from premature underflow when groups grow large, while remaining pure deterministic double arithmetic. Aliases people or group_size for n, and days or labels for d, are accepted. Missing fields, non-integers, n below one, d below one, and values above the maxima all fail with invalid_input and are not charged. After validation, if n is greater than d the pigeonhole principle applies immediately: at least two people must share a day, so probability is one, all_distinct is zero, and guaranteed is true. Otherwise the engine accumulates the log of each factor (d minus i) over d for i from one through n minus one, exponentiates the sum, clamps the floating result into the unit interval, and returns probability equal to one minus that all_distinct value. The response fields are n, d, probability, all_distinct, and guaranteed.

Practical use, limits, pricing, and delivery channels

Use the browser tool when you want an instant collision probability while teaching discrete probability, designing a matching game, or checking why twenty-three is the famous classroom threshold for three hundred sixty-five days. Results are fully deterministic: the same n and d always yield the same probability, the same complement, and the same guaranteed flag. There is no language model, no external probability service, and no randomness, so the capability is safe to pin in continuous-integration checks and reproducible lesson materials. Each successful request is one billable item at $0.002; failed validation does not consume balance. Accepted ranges keep the O(n) product bounded for Worker isolates while covering classroom calendars, multi-year label spaces, and synthetic buckets far larger than a single year. Wire the endpoint into probability tutorials, coding-interview oracles, scheduling collision estimators, or cryptographic teaching demos where you prefer the classic complement product over approximate sampling histograms that never quite settle to the true value.

Classroom and textbook checks

Teachers and students verify the classic n=23, d=365 threshold and explore how changing the calendar length moves the fifty-percent crossing without hand-computing long products.

How do I compute the birthday paradox probability?

Send JSON with integers n (people) and d (possible days) to prob.birthday_paradox. The response includes probability of at least one shared day, the all_distinct complement, and a guaranteed flag when n exceeds d.

Read the full KIT documentation →