[Python-checkins] Minor code clean-up for the factor() recipe (GH-108114)

rhettinger webhook-mailer at python.org
Fri Aug 18 13:14:01 EDT 2023


https://github.com/python/cpython/commit/6db39b1460727e8820b45e5c083e5839af0352aa
commit: 6db39b1460727e8820b45e5c083e5839af0352aa
branch: main
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2023-08-18T12:13:58-05:00
summary:

Minor code clean-up for the factor() recipe (GH-108114)

files:
M Doc/library/itertools.rst

diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 730736bbb59ed..d0bb469697019 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -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:



More information about the Python-checkins mailing list