Skip to content

Commit 3bfd0e6

Browse files
committed
fix(maths): raise documented ValueError for negative inputs in res()
1 parent 25bcced commit 3bfd0e6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

maths/largest_of_very_large_numbers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import math
44

55

6-
def res(x, y):
6+
def res(x: int | float, y: int | float) -> float | int:
77
"""
88
Reduces large number to a more manageable number
99
>>> res(5, 7)
@@ -17,6 +17,8 @@ def res(x, y):
1717
...
1818
ValueError: expected a positive input
1919
"""
20+
if x < 0:
21+
raise ValueError("expected a positive input")
2022
if 0 not in (x, y):
2123
# We use the relation x^y = y*log10(x), where 10 is the base.
2224
return y * math.log10(x)

0 commit comments

Comments
 (0)