The Birthday Paradox by Mihailo Despotovic, September 2005

How many people must be in a room before two of them probably share a birthday? Surprisingly few: with 23 people the chance is already better than even. The chance that everyone's birthday differs is 365/365 × 364/365 × 363/365 × …, one factor per person, and the chance of a shared birthday is 1 minus that.

Try it

The original table, 0 to 89 people

    
The original Java code: BP.java
/**
 * @author Mihailo Despotovic
 * @since Sep 18, 2005 3:04:26 PM
 */
public class BP
{
  private static final double DAYS = 365d;

  public static void main(String[] args)
  {
    System.out.println("Probabilities that 2 people in the room will have the same birthday:");
    System.out.println("People --- Probability");
    for(int people=0; people<90; people++)
    {
      double p = 1;
      for(int i=0; i<people; i++)
        p *= (DAYS-i)/DAYS;
      System.out.println(people + " --- " + (1-p));
    }
  }
}