This phenomenon actually has a name -- it is called the birthday paradox, and it turns out it is useful in several different areas (for example, cryptography and hashing algorithms). You can try it yourself - the next time you are at a gathering of 20 or 30 people (in a classroom, at the office, in a chat room, at a party, etc.), ask everyone for their birth dates. It is likely that two people in the group will have the same birthday. It always surprises people!
The reason this is so surprising is because we are used to comparing our particular birthdays with others. For example, if you meet a person randomly and ask him or her for their birthday, the chance of the two of you having the same birthday is only 1/365 (0.27%). In other words, the probability of any two individuals having the same birthday is extremely low. Even if you ask 20 people, the probability is still low - less than 5%. So we feel like it is very rare to meet anyone with the same birthday as our own.
When you put 20 people in a room however, the thing that changes is the fact that all 20 people are now asking the other 19 people about their birthdays. Each individual person only has a small (less than 5%) chance of success, but you are trying it 20 times. That increases the probability dramatically.
If you want to calculate the exact probability, there are two different ways to do it. The first way involves counting the pairs of people in the room. In a room of 20 people there are 190 possible pairs (20*19/2). Each pair has a probability of success of 1/365 = 0.27%, so a probability of failure of 1 - 0.27% = 99.726%. If you raise the probability of failure to the 190th power, then you get:
So the probability of success is (100 - 59%) = 41%. It turns out your friend was slightly off - you have to have 23 people in the room to get 50/50 odds. If you have 42 people in the room the probability rises to a 90% chance of two people having the same birthday!
The other way to look at it is like this. Let's say you have a big wall calendar with all 365 days on it. You walk in and put a big X on your birthday. The next person who walks in has only a 364 possible open days available, so the probability of the two dates not colliding is 364/365. The next person has only 363 open days, so the probability of not colliding is 363/365. If you multiply the probabilities for all 20 people not colliding, then you get:
364/365 * 363/365 * … 365-n+1/365
That's the probability of no collisions, so the probability of collisions is 1 minus that number.
The next time you are with a group of 30 people, try it!