%Peng5.28

P = [];
for n=2:40
    hits = 0;
    for l = 1:5000
        
        Random_number = randi(365,[1,n]);
        basket = zeros(1,365);

        for i=1:n
            basket(Random_number(i)) = basket(Random_number(i))+1;
        end
        m = max(basket);

        if m>1
            hits = hits+1;
        end
    end
   
    probability = hits/5000;
    P = [P; probability];
end
P
plot(P)