// Arup Guha
// 8/25/09

// Calculates the probability that a pair of people in a room of N people
// share a common birthday, assuming that each birthday is equally likely.

#include <stdio.h>

#define N 30
#define DAYSINYEAR 366

int main() {
    
    double probDiff = 1.0;
    int i;
    
    // Multiply the initial probability by the probability that each
    // subsequent person as a different birthday.
    for (i=1; i<N; i++)
        probDiff = probDiff*(DAYSINYEAR - i)/DAYSINYEAR;
        
    // The probability we seek is the opposite.
    double probMatch = 1 - probDiff;
    
    // Print this out.
    printf("The probability that at least two people have the same birthday ");
    printf("is %.4lf\n", probMatch);
    
    system("PAUSE");
    return 0;
}
