// 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 DAYSINYEAR 366

int main() {
    
    int N;
    
    double probDiff = 1.0;
    
    // Try out different number of people in the room.
    for (N=0; N<78; N++) {
    
        // Multiply the initial probability by the probability that each
        // subsequent person as a different birthday.
        probDiff = probDiff*(DAYSINYEAR - N)/DAYSINYEAR;
        
        // The probability we seek is the opposite.
        double probMatch = 1 - probDiff;
    
        // Print this out.
        printf("The prob that two people out of %d ", N+1);
        printf("have the same bday is %.4lf\n", probMatch);
    }
    
    system("PAUSE");
    return 0;
}
