Skip to content

Instantly share code, notes, and snippets.

@kissge
Created August 12, 2023 22:00
Show Gist options
  • Save kissge/7c80ebedfc795efc074bdd3a6a4e6b1b to your computer and use it in GitHub Desktop.
Save kissge/7c80ebedfc795efc074bdd3a6a4e6b1b to your computer and use it in GitHub Desktop.
誕生日のパラドックス
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