]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Minor code clean-up for the factor() recipe (GH-108114)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Fri, 18 Aug 2023 17:13:58 +0000 (12:13 -0500)
committerGitHub <noreply@github.com>
Fri, 18 Aug 2023 17:13:58 +0000 (12:13 -0500)
Doc/library/itertools.rst

index 730736bbb59ed9665e6832d97c8ae657340eff50..d0bb46969701987b97c9f91c9fd258d37742fa99 100644 (file)
@@ -1048,9 +1048,7 @@ The following recipes have a more mathematical flavor:
        # factor(1_000_000_000_000_007) --> 47 59 360620266859
        # factor(1_000_000_000_000_403) --> 1000000000000403
        for prime in sieve(math.isqrt(n) + 1):
-           while True:
-               if n % prime:
-                   break
+           while not n % prime:
                yield prime
                n //= prime
                if n == 1: