Created
March 3, 2024 09:28
-
-
Save SimonBrandner/392d6e5cb1a66c2e539c532c07a5830a to your computer and use it in GitHub Desktop.
The hat-check problem solution calculator
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
import math | |
n = int(input()) | |
def some_sum(): | |
s = 0 | |
for m in range(1, n+1): | |
s += ((-1)**(m-1)) * (1/math.factorial(m)) | |
return s | |
P = 1 - some_sum() | |
print(P) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment