This commit is contained in:
MaximSmolskiy
2024-08-25 15:44:08 +03:00
parent e6790b5407
commit fba4edf1cd
12 changed files with 21 additions and 36 deletions

View File

@@ -31,8 +31,7 @@ def binomial_coefficient(n: int, k: int) -> int:
"""
result = 1 # To kept the Calculated Value
# Since C(n, k) = C(n, n-k)
if k > (n - k):
k = n - k
k = min(k, n - k)
# Calculate C(n,k)
for i in range(k):
result *= n - i