Skip to content

Instantly share code, notes, and snippets.

@mokjpn
Created December 9, 2015 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokjpn/9637ca00fbc7457287b9 to your computer and use it in GitHub Desktop.
Save mokjpn/9637ca00fbc7457287b9 to your computer and use it in GitHub Desktop.
早押しクイズでn問先取の時,問題をx問用意した時にどのくらいの確率で勝ち抜け者が出るか.ただし一人も正解がない場合はないものとする.
# 早押しクイズでn問先取の時,問題をx問用意した時にどのくらいの確率で勝ち抜け者が出るか.ただし一人も正解がない場合はないものとする.
nquiz <- function(x,n) {
if(n > x) {
stop("n must be smaller than or equal to x")
}
sum(sapply(n:x, function(xx) { ncol(combn(x,xx))})) / (2^x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment