From: Raymond Hettinger Date: Mon, 2 Oct 2023 19:19:46 +0000 (-0500) Subject: [3.12] Sync factor() recipe with main branch (gh-110231) X-Git-Tag: v3.12.1~402 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=221c8d64e672ff50affbb10cacc81d0586752eef;p=thirdparty%2FPython%2Fcpython.git [3.12] Sync factor() recipe with main branch (gh-110231) --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 8a1c83aa3a28..5846d784c88c 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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: