diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index c3831eb2bc5..69acc7c654d 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -1257,6 +1257,17 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: K. = GF(3^60) sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) 42391158275216203514294433200 + + TESTS: + + Check that :issue:`38489` is fixed:: + + sage: from sage.groups.generic import order_from_multiple + sage: plist = [43, 257, 547, 881] + sage: m = prod(plist[:-1]) + sage: elt = Zmod(m)(plist[-1]) + sage: order_from_multiple(elt, m, plist=plist) + 6044897 """ Z = integer_ring.ZZ @@ -1325,6 +1336,8 @@ def _order_from_multiple_helper(Q, L, S): if abs(sum_left + v - (S / 2)) > abs(sum_left - (S / 2)): break sum_left += v + if not 0 < k < l: + k = l // 2 L1 = L[:k] L2 = L[k:] # recursive calls