From fb8b7efc2319fc034b32a556169f5014c0ca09ec Mon Sep 17 00:00:00 2001 From: Pedram_Mohajer <48964282+pedram-mohajer@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:57:20 -0500 Subject: [PATCH 1/2] Update power.py --- divide_and_conquer/power.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/divide_and_conquer/power.py b/divide_and_conquer/power.py index f2e023afd536..5f26e1520248 100644 --- a/divide_and_conquer/power.py +++ b/divide_and_conquer/power.py @@ -2,6 +2,20 @@ def actual_power(a: int, b: int): """ Function using divide and conquer to calculate a^b. It only works for integer a,b. + + :param a: The base of the power operation, an integer. + :param b: The exponent of the power operation, a non-negative integer. + :return: The result of a^b. + + Examples: + >>> actual_power(3, 2) + 9 + >>> actual_power(5, 3) + 125 + >>> actual_power(2, 5) + 32 + >>> actual_power(7, 0) + 1 """ if b == 0: return 1 @@ -13,6 +27,10 @@ def actual_power(a: int, b: int): def power(a: int, b: int) -> float: """ + :param a: The base (integer). + :param b: The exponent (integer). + :retuen: The result of a^b, as a float for negative exponents. + >>> power(4,6) 4096 >>> power(2,3) From 027f1ec0201cfcebada4b1c782bf5ebfd8ef8e76 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Sat, 1 Jun 2024 02:05:12 -0700 Subject: [PATCH 2/2] Update divide_and_conquer/power.py --- divide_and_conquer/power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/divide_and_conquer/power.py b/divide_and_conquer/power.py index 5f26e1520248..faf6a3476d40 100644 --- a/divide_and_conquer/power.py +++ b/divide_and_conquer/power.py @@ -29,7 +29,7 @@ def power(a: int, b: int) -> float: """ :param a: The base (integer). :param b: The exponent (integer). - :retuen: The result of a^b, as a float for negative exponents. + :return: The result of a^b, as a float for negative exponents. >>> power(4,6) 4096