File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,20 @@ def actual_power(a: int, b: int):
22 """
33 Function using divide and conquer to calculate a^b.
44 It only works for integer a,b.
5+
6+ :param a: The base of the power operation, an integer.
7+ :param b: The exponent of the power operation, a non-negative integer.
8+ :return: The result of a^b.
9+
10+ Examples:
11+ >>> actual_power(3, 2)
12+ 9
13+ >>> actual_power(5, 3)
14+ 125
15+ >>> actual_power(2, 5)
16+ 32
17+ >>> actual_power(7, 0)
18+ 1
519 """
620 if b == 0 :
721 return 1
@@ -13,6 +27,10 @@ def actual_power(a: int, b: int):
1327
1428def power (a : int , b : int ) -> float :
1529 """
30+ :param a: The base (integer).
31+ :param b: The exponent (integer).
32+ :return: The result of a^b, as a float for negative exponents.
33+
1634 >>> power(4,6)
1735 4096
1836 >>> power(2,3)
You can’t perform that action at this time.
0 commit comments