Skip to content

Instantly share code, notes, and snippets.

@chemacortes
Last active February 27, 2020 00:26
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 chemacortes/6b4da47c4ac08595be7521bdb780f744 to your computer and use it in GitHub Desktop.
Save chemacortes/6b4da47c4ac08595be7521bdb780f744 to your computer and use it in GitHub Desktop.
Formula for calculating the birthday paradox
def birthday(n: Int) = {
1 - (0 until n).map(1 - BigDecimal(_) / 365).product
}
assert(birthday(23) == BigDecimal("0.5072972343239854072254172283370325"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment