Skip to content

Commit ab5dfe3

Browse files
committed
Update ncr_combinations.py
1 parent 725abb4 commit ab5dfe3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

maths/ncr_combinations.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Generalized combinations (n choose r) calculator for real total and integer choose.
3-
Wikipedia URL: https://en.wikipedia.org/wiki/Binomial_coefficient
3+
Wikipedia URL:
4+
https://en.wikipedia.org/wiki/Binomial_coefficient
45
"""
56

67
from math import factorial as math_factorial
@@ -70,5 +71,8 @@ def combinations(total: float, choose: int) -> float:
7071

7172
# Example usage
7273
total_input = float(input("Enter total (real number): ").strip() or 0)
73-
choose_input = int(input("Enter choose (integer): ").strip() or 0)
74-
print(f"combinations({total_input}, {choose_input}) = {combinations(total_input, choose_input)}")
74+
choose_input = int(input("Enter choose (non-negative integer): ").strip() or 0)
75+
print(
76+
f"combinations({total_input}, {choose_input}) = "
77+
f"{combinations(total_input, choose_input)}"
78+
)

0 commit comments

Comments
 (0)