Birthday paradox

The code is giving wrong output

link: https://ide.codingblocks.com/s/197770

Hi @Mansi2103 , your logic is little flawed , let me explain the correct

Let the probability that two people in a room with n have same birthday be P(same). P(Same) can be easily evaluated in terms of P(different) where P(different) is the probability that all of them have different birthday.

P(same) = 1 – P(different)

P(different) can be written as 1 x (364/365) x (363/365) x (362/365) x …. x (1 – (n-1)/365)
but what you are doing is calculation P(different) as 1 x (364/365) x (364/365) x (364/365) x …. x (364/365)

here , you can refer to the code of using above logic

In case of any doubt feel free to ask :slight_smile:
If you got the answer mark your doubt as resolved
if you liked the answer then hit a like :+1: