# calculates probability of shared birthday # in group of n people, for n in 1:100 # # first initialize vector of probs probcomp = rep(NA, times=100) # # now begin loop through values of n for (n in 1:100) { # # initialize the complement probability probcomp[n] = 1 # # now begin loop to calculate product for (i in 1:n) { probcomp[n]=probcomp[n]*(365-i+1)/365 } } # # now prepare to graph results numpeople = (1:n) probshare = 1 - probcomp plot(numpeople,probshare)