Created
August 12, 2023 22:00
-
-
Save kissge/7c80ebedfc795efc074bdd3a6a4e6b1b to your computer and use it in GitHub Desktop.
誕生日のパラドックス
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(days: int, people: int): | |
all_different = 1 | |
for i in range(1, people): | |
all_different *= days - i | |
return 1 - all_different / (days ** (people - 1)) | |
birthday(365, 23) | |
# => 0.5072972343239854 | |
birthday(18000000, 10000) | |
# => 0.9378381908765165 | |
birthday(18000000000, 50000) | |
# => 0.06708680388588473 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment