From 32bcb81c21019d8c063122e9ff0dda2aba595453 Mon Sep 17 00:00:00 2001 From: Kamil <32775019+quant12345@users.noreply.github.com> Date: Mon, 9 Oct 2023 22:48:23 +0500 Subject: [PATCH] Update carmichael_number.py Made changes taking into account the addition: from maths.greatest_common_divisor import greatest_common_divisor. Now instead of gcd it is used: greatest_common_divisor. --- maths/carmichael_number.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/maths/carmichael_number.py b/maths/carmichael_number.py index 439ae7f7a538..1c297f8cb117 100644 --- a/maths/carmichael_number.py +++ b/maths/carmichael_number.py @@ -11,23 +11,7 @@ https://en.wikipedia.org/wiki/Carmichael_number """ - -def gcd(a: int, b: int) -> int: - """ - - Examples: - >>> gcd(9, 3) - 3 - - >>> gcd(2, 1) - 1 - """ - - if a < b: - return gcd(b, a) - if a % b == 0: - return b - return gcd(b, a % b) +from maths.greatest_common_divisor import greatest_common_divisor def power(x: int, y: int, mod: int) -> int: @@ -72,7 +56,7 @@ def is_carmichael_number(n: int) -> bool: b = 2 while b < n: - if gcd(b, n) == 1 and power(b, n - 1, n) != 1: + if greatest_common_divisor(b, n) == 1 and power(b, n - 1, n) != 1: return False b += 1 return True