// How many people does it take to have two of them
// with matchingbirthdays...
void setup() {
int N = 100;
int count = 0;
boolean[] birthday = new boolean[365];
// Do N trials
for (int trial = 1; trial <= N; trial++) {
// Do one trial
int peopleCount = 0;
boolean found = false;
// initialize birthday[]
for (int i=0; i < birthday.length; i++) {
birthday[i] = false;
}
while (!found) {
peopleCount = peopleCount + 1; // a person enters
int day = int(random(365)); // their birthday
// record birthday
if (birthday[day]) {
found = true;
} else {
birthday[day] = true;
}
}
println(peopleCount);
count = count + peopleCount;
}
// Output result
println(float(count)/N);
} // setup();