From 606d8447244214e917eef9c5f840a5b4d0bbb9d1 Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:34:53 +0530 Subject: [PATCH 1/3] Add typing to binary_exp_mod.py --- maths/binary_exp_mod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/binary_exp_mod.py b/maths/binary_exp_mod.py index df688892d690..c74a13f7fb7d 100644 --- a/maths/binary_exp_mod.py +++ b/maths/binary_exp_mod.py @@ -1,4 +1,4 @@ -def bin_exp_mod(a, n, b): +def bin_exp_mod(a: int, n: int, b: int) -> int: """ >>> bin_exp_mod(3, 4, 5) 1 From 0612505ae4c3a4383c1c3a8e784e8ec06345e89e Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:37:12 +0530 Subject: [PATCH 2/3] Update binary_exp_mod.py --- maths/binary_exp_mod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/binary_exp_mod.py b/maths/binary_exp_mod.py index c74a13f7fb7d..17549bf6e8a3 100644 --- a/maths/binary_exp_mod.py +++ b/maths/binary_exp_mod.py @@ -1,4 +1,4 @@ -def bin_exp_mod(a: int, n: int, b: int) -> int: +def bin_exp_mod(a: int, n: float, b: int) -> int: """ >>> bin_exp_mod(3, 4, 5) 1 From d26b4c73afa31d8aa59c97029dbc05382af72f95 Mon Sep 17 00:00:00 2001 From: Saksham Chawla <51916697+saksham-chawla@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:53:42 +0530 Subject: [PATCH 3/3] review changes --- maths/binary_exp_mod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/binary_exp_mod.py b/maths/binary_exp_mod.py index 17549bf6e8a3..8893182a3496 100644 --- a/maths/binary_exp_mod.py +++ b/maths/binary_exp_mod.py @@ -1,4 +1,4 @@ -def bin_exp_mod(a: int, n: float, b: int) -> int: +def bin_exp_mod(a: int, n: int, b: int) -> int: """ >>> bin_exp_mod(3, 4, 5) 1 @@ -13,7 +13,7 @@ def bin_exp_mod(a: int, n: float, b: int) -> int: if n % 2 == 1: return (bin_exp_mod(a, n - 1, b) * a) % b - r = bin_exp_mod(a, n / 2, b) + r = bin_exp_mod(a, n // 2, b) return (r * r) % b