生日悖论问题(想出主意但无法产生预期的结果)

粗略的想法:假设人们一次进入一个房间。人们必须如何进入,直到两个人过生日?违反直觉的是,当23个人进入房间后,两个人大约有50-50的机会分享生日。这种现象被称为生日问题或生日悖论。

public class Main {
public static void main(String[] args) {
    int n = Integer.parseInt(args[0]); // number of possible birthdates (365)
    int trials = Integer.parseInt(args[1]); // number of trials I want to conduct
    int people = 0;
    int csum = 0; // cumulative sum
    int probability = 0; // probability = csum / trials (decimal form)
    int [] data = new int[trials];
    for (int i = 0; i < trials; i++) {
        boolean[] hasSameBirthday = new boolean[n];
        while (true) { // find out after how many people enter room before birthday match
            people ++;
            int d = (int) (n * Math.random());
            if (hasSameBirthday[d]) break;
            hasSameBirthday[d] = true;
        }
        data[i] += people; // append people value into array
        csum += people;
        probability = csum / trials;
    }
    for (int i = 1; i < 24; i++) {
        System.out.println(i + "\t" + data[i] + "\t" +  probability); // attempt to return values(shown in picture below)
    }
}

}

I want to find the sum of all the experiments taken before the x th person enters the roomI know that probability is csum / trials but I cant find csum after many tries...expected output

这是预期的输出^