% 確率を解析的に計算

diff = 1;
answer = [];
for k=2:50
    diff = diff*(365-k+1)/365;
    same = 1 - diff;
    fprintf("      人数 %2d      確率 %.8f\n", k, same);
    answer = [ answer; k, same ];
end

plot(answer(:,1), answer(:, 2));
xlabel('人数');
ylabel('同じ誕生日の人がいる確率');
saveas(gcf, 'same_birthday.png');
%saveas(gcf, 'same_birthday.eps');
