From 221c8d64e672ff50affbb10cacc81d0586752eef Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 2 Oct 2023 14:19:46 -0500 Subject: [PATCH] [3.12] Sync factor() recipe with main branch (gh-110231) --- Doc/library/itertools.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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: -- 2.47.3