Last active
February 27, 2020 00:26
-
-
Save chemacortes/6b4da47c4ac08595be7521bdb780f744 to your computer and use it in GitHub Desktop.
Formula for calculating the birthday paradox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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