]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Sync factor() recipe with main branch (gh-110231)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Mon, 2 Oct 2023 19:19:46 +0000 (14:19 -0500)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2023 19:19:46 +0000 (14:19 -0500)
Doc/library/itertools.rst

index 8a1c83aa3a2804c8f3e115404ebd945e496b96bb..5846d784c88cccd6db7869ae49e7c84ba5ed2af9 100644 (file)
@@ -1119,9 +1119,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: