function[prob]=trial3(trialmax);

%loop through different amounts of persons
for a=2:70
    
    %for given amount of people, loop over addition of each person, once
    %match occurs, exit loop
    totalcount(a)=0;
    xaxis(a)=a;
    for trials=1: trialmax
   
    for i=1:a
         match=0;
         birthday(i)=ceil(365*rand);
         j=1;
           while j<i 
                  if birthday(i)==birthday(j),match=1;,break,end;
                      j=j+1;
                  end
         if match==1,break,end;
     end
     if match==1;, count=1;,end;
     if match==0;, count=0;,end;
     totalcount(a)=totalcount(a)+count;
 end
 prob(a)=totalcount(a)/trialmax;
 
 
end

plot(xaxis,prob,'*');       