We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2e88127 commit f24ceb0Copy full SHA for f24ceb0
maths/combinations.py
@@ -26,15 +26,14 @@ def combinations(n: int, k: int) -> int:
26
1
27
28
>>> combinations(-4, -5)
29
- Invalid value for n and/or k given.
30
- -1
+ Traceback (most recent call last):
+ ValueError: Please enter positive integers for n and k where n >= k
31
"""
32
33
# If either of the conditions are true, the function is being asked
34
# to calculate a factorial of a negative number, which is not possible
35
if n < k or k < 0:
36
- print("Invalid value for n and/or k given.")
37
- return -1
+ raise ValueError("Please enter positive integers for n and k where n >= k")
38
return int(factorial(n) / ((factorial(k)) * (factorial(n - k))))
39
40
0 commit comments