The Birthday Problem is a probability problem that asks how many people you need to have in a room so that there is a greater than 50% chance that two people will share a birthday.
Here's the Matlab code to calculate the probability of having at least two people with the same birthday:
main.m198 chars10 lines
To test the code, you can call the function with a number of people as parameter:
main.m42 chars6 lines
This means that for 23 people in a room, the probability of having at least two people with the same birthday is 50.73%.
gistlibby LogSnag