Question 735220
This is fun,

This birthday problem asks whether any of the people in a given group has a birthday matching any of the others — not one in particular. In the example, there are 40 people in the class, comparing the birthday of the first person in the class to the others allows 39 chances for a matching birthday, the second person in the class to the others allows 38 chances for a matching birthday, third person has 37 chances, and so on. Hence total chances are: 39+38+37+....+1 = (39*(39+1))/2=780, so comparing every person to all of the others allows 780 distinct chances (combinations): in a group of 40 people there is the combination of 40 people taken 2 at a time equals (40*39)/2 = 780 pairs.

We assume that the 365 possible birthdays are equally likely.  Let P(A) be the probability that of at least two people in the room having the same birthday and P(A') be the probability of there not being any two people having the same birthday.  Then P(A) = 1 - P(A').

P(A') can be described as 40 independent events, P(A') could be calculated as P(1) × P(2) × P(3) × ... × P(40). The 40 independent events correspond to the 40 people, and can be defined in order. Each event can be defined as the corresponding person not sharing his/her birthday with any of the previously analyzed people. For Event 1, there are no previously analyzed people. Therefore, the probability, P(1), that person number 1 does not share his/her birthday with previously analyzed people is 1, or 100%.  We continue in this fashion with the resulting equation:

P(A') = 365/365 × 364/365 × 363/365 × 362/365 × ... × 326/365

collecting terms we have

P(A') = ((1/365)^40) * (365 × 364 × 363 × ... × 326)

and P(A) = 1 - P(A')