We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bcd0b50 commit 9e6c74cCopy full SHA for 9e6c74c
divide_and_conquer/power.py
@@ -26,15 +26,17 @@ def actual_power(a: int, b: int):
26
else:
27
return half * half
28
29
+
30
def power(a: int, b: int) -> float:
31
"""
32
:param a: The base (integer).
33
:param b: The exponent (integer).
34
:return: The result of a^b, as a float for negative exponents.
35
36
if b < 0:
- return 1 / actual_power(a, -b)
37
+ return 1 / actual_power(a, -b)
38
return actual_power(a, b)
39
40
41
if __name__ == "__main__":
- print(power(-2, -3)) #output -0.125
42
+ print(power(-2, -3)) # output -0.125
0 commit comments