From e9842c827909bf3e68e65177e1a7ef2b3119267a Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Mon, 8 Jan 2024 22:05:38 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- euclid.py | 5 +---- legendre_symbol_small.py | 5 +---- polysolv.py | 9 ++++----- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/euclid.py b/euclid.py index 3c8138d..bc93114 100644 --- a/euclid.py +++ b/euclid.py @@ -16,7 +16,4 @@ def gcd2(a, b): def gcd3(a, b): - if b == 0: - return a - else: - return gcd(b, a % b) + return a if b == 0 else gcd(b, a % b) diff --git a/legendre_symbol_small.py b/legendre_symbol_small.py index 8b45132..c057852 100644 --- a/legendre_symbol_small.py +++ b/legendre_symbol_small.py @@ -7,10 +7,7 @@ def legendre_symbol(a, p): ls = pow(a, (p - 1) // 2, p) - if ls == p - 1: - return -1 - else: - return ls + return -1 if ls == p - 1 else ls def test(): diff --git a/polysolv.py b/polysolv.py index 53750d7..a0d0852 100644 --- a/polysolv.py +++ b/polysolv.py @@ -103,12 +103,11 @@ def factor_poly(Poly, Grade): terms = [] for grade in range(Grade, 1, -1): result = poly_synthetic_div_complete_step(P, grade) - if result != None: - P, term = result - terms += term - else: + if result is None: break - terms += ["(%s)" % poly_to_text(P, grade)] + P, term = result + terms += term + terms += [f"({poly_to_text(P, grade)})"] print(("=" * 60)) s = sanitize("".join(terms)) print(("Result:", s))