// Arup Guha
// 1/9/2013
// Calculates theoretical expectation for number of people we
// must ask for birthdays before we get the first repeat.

#include <stdio.h>

#define N 365

int main() {

    double ans = 0;

    // Loop through each possible number of days.
    int i;
    for (i=2; i<=N+1; i++) {

        // In expectation, we multiply the value (# days) so we store this first.
        double term = i;

        // Here we multiply the probability of the persons 1 to i-1 having distinct bdays.
        int j;
        for (j=N-1; j>=N-i+2; j--)
            term = term*j/N;

        // Finally, we multiply in the probability of the last person having a matching bday.
        term = term*(i-1)/N;

        // Add this in...
        ans = ans + term;
    }

    // Voila, our answer!
    printf("Expected number of days = %lf.\n", ans);

    return 0;
}
