There is a big line of people waiting outside a theater for buying tickets. The theater owner comes out and announces that the first person to have a birthday same as someone standing before him in the line gets a free ticket. Where will you stand to maximize your chance?
17

mathinterviewquestionsprobability

13
accepted

You should stand 20th in line. The chance of you winning is the chance of none of the people before you winning AND you having a birthday the same as someone before you in line. The calculations are easy if you realise that when you know nobody before you won, you know they all have different birthdays, so the probability that you have the same birthday as someone before you in line is then (k1)/365. So:
In C++ code:
This code tells me I should stand 20th in line, and I have 3.23199% chance of winning. EDIT: Added one line to the code to print the total sum of probabilities. This should be 1, and it is 1 on my machine (Well, almost. There are some rounding errors). 
12

I think the explicit probability function is:
Which confirms that standing 20th in the row maximizes your probability As for the cumulative probability function:
Edit Now suppose we want to solve the problem for a year with any number of days. This could be used to solve the same kind of problem with "People whose birthday is on the same day of the week" or "People whose birthday is on the same Chinese calendar animal". Here you can see the optimal position in the queue, as a function of the number of days in a year: 