diff --git a/polynomial.py b/polynomial.py index 117af5ab5c03f4102042788627dcde93d62940d9..ef82cc09dbbebd55a06d6d882045050f75f1f8d4 100644 --- a/polynomial.py +++ b/polynomial.py @@ -60,6 +60,12 @@ class Polynomial: for i in range(len(a)): result[i] = a[i] % other + for i in reversed(range(len(result))): + if result[i] ==0: + del result[i] + else: + break + return Polynomial(tuple(result)) def __str__(self):