Skip to content
Tech News
← Back to articles

When is your birthday? The math behind hash collisions

read original get Hash Collision Debugger Tool → more articles
Why This Matters

This article explores the surprising probability that in a group of just 23 people, there's a 50% chance two share the same birthday, illustrating fundamental concepts of probability and the birthday paradox. Understanding these principles is crucial for the tech industry, especially in areas like cryptography and data hashing, where collision probabilities can impact security and system integrity.

Key Takeaways

Note: This post turned out a little different from the previous ones. It's more of an essay than a dialogue. I tried restructuring it multiple times, but it kept wanting to be linear. And you know, sometimes the topic just has its own shape, so I left it like this. Enjoy!

What is the probability that you are sharing the same birthday with people around you? Well, if you’re alone in the room, then it’s most certainly zero. Also the more people there are around, the higher the chances should get. But what if I told you that in a room with only 23 people there’s already a 50% chance for two of them to have matching birthdays? And I can quite easily prove it with just school math.

What does it mean to calculate a probability for at least two people to have a matching birthday? It’s the same as calculating the inverse probability for no one in the group to be born on the same day:

\[P(\text{at least one match}) = 1 - P(\text{no matches})\]

No matches means every birthday is unique. That means the first person can be born on any of the 365 days, person 2 must be born on a different day, so he has only 364 days to choose from, person 3 has only 363 days to choose from… and so on. So let’s take n for the number of people in the room and derive this formula:

\[P(\text{no matches}) = \frac{365}{365} \cdot \frac{364}{365} \cdot \frac{363}{365} \dots \frac{365-n+1}{365} = \frac{365!}{365^n(365-n)!}\]

for n=23:

\[P(\text{no matches}) = \frac{365!}{365^{23}(365-23)!}= 0.4927\]

…or about 50%.

... continue reading