inst/snippet/birthday-problem.R

# calculates prob of shared birthday
birthdayprob <- function(n) { 
        last <- 366 - n
        1 - ( prod(seq(last,365)) / 365^n )
}

birthdayprob(10)
cbind(20:25,sapply(20:25,birthdayprob))

Try the fastR package in your browser

Any scripts or data that you put into this service are public.

fastR documentation built on May 1, 2019, 11:18 p.m.