%Birthdays
%parameters

n=10000;

pr=zeros(1,n);
t=[1:n];
pr(1)=1;
for (i=[2:n])
    pr(i)=pr(i-1)*(1-(i-1)/n);
end;
clf reset;
%grid on;
ub=min(n, floor(4*sqrt(n)));
xlim([1,ub]);
ylim([0,1]);
hold on;
%pr(660)
pr=1-pr;
plot(t, pr, 'Color', [1,0,0]);
for (i=[1:ub])
     display(sprintf('%d %1.6f', t(i), pr(i)));
end
hold on;
%legend('duplicate birthday prob.');
 
str=strcat('Duplicate birthday prob. with ', sprintf(' n=%d', n));
title(str);
xlabel('k');
ylabel('prob.');

hold off;
