Skip to content

Commit 53b5e81

Browse files
Update power.py
1 parent d1f4ea4 commit 53b5e81

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

divide_and_conquer/power.py

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ def power(a: int, b: int) -> float:
3232
:param a: The base (integer).
3333
:param b: The exponent (integer).
3434
:return: The result of a^b, as a float for negative exponents.
35+
36+
>>> power(4,6)
37+
4096
38+
>>> power(2,3)
39+
8
40+
>>> power(-2,3)
41+
-8
42+
>>> power(2,-3)
43+
0.125
44+
>>> power(-2,-3)
45+
-0.125
3546
"""
3647
if b < 0:
3748
return 1 / actual_power(a, -b)

0 commit comments

Comments
 (0)