File tree 1 file changed +18
-0
lines changed
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):
2
2
"""
3
3
Function using divide and conquer to calculate a^b.
4
4
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
5
19
"""
6
20
if b == 0 :
7
21
return 1
@@ -13,6 +27,10 @@ def actual_power(a: int, b: int):
13
27
14
28
def power (a : int , b : int ) -> float :
15
29
"""
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
+
16
34
>>> power(4,6)
17
35
4096
18
36
>>> power(2,3)
You can’t perform that action at this time.
0 commit comments