- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The birthday paradox is a very famous problem in the section of probability.

**Problem Statement** − There are several people at a birthday party, some are having the same birthday collision. We need to find the approximate number of people at a birthday party on the basis of having the same birthday.

In the probability, we know that the chance of getting ahead is 1/2, same as if we have some coins, the chance of getting 10 heads is 1/100 or 0.001.

Let us understand the concept.

The chance of two people having the different birthday is $$\frac{364}{365}$$ which is $$\lgroup1-\frac{1}{365}\rgroup$$ in a Non-leap year.

Thus, we can say that the first person having the probability of a specific birthday is ‘1’ and for others, it would be different which is,

P(different) = $$1\times\lgroup1-\frac{1}{365}\rgroup\times\lgroup1-\frac{2}{365}\rgroup\times\lgroup1-\frac{3}{365}\rgroup\times\lgroup1-\frac{4}{365}\rgroup...$$

Thus,

P(same) = 1 − P(different)

For example, the number of people having the same birthday for which probability is 0.70.

N = √2 × 365 × log(1-1/p)

N = √2 × 365 × log(1-1/0.70) = 30

Thus, the total approximate no. of people having the same birthday is 30.

import math def findPeople(p): return math.ceil(math.sqrt(2*365*math.log(1/(1-p)))) print(findPeople(0.70))

Running the above code will generate the output as,

30

- Related Questions & Answers
- Birthday Paradox in C++
- Birthday Reminder Application in Python
- C++ program to print Happy Birthday
- Why do you celebrate your birthday every year?
- My husband wants me to wear a yellow gown on his birthday but I don't like the color. How do I handle this situation?
- ChainMap in Python
- Namedtuple in Python
- Deque in Python
- OrderedDict in Python
- Multiprocessing In Python
- Quine in Python
- Underscore(_) in Python
- Keywords in Python
- Generators in Python?
- Counters in Python?

Advertisements