From 1bbedc9659c82794e417f1eb72887bcde4b905ca Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 2 Oct 2023 11:53:03 -0500 Subject: [PATCH] Sync factor() recipe with main branch --- 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 8a1c83aa3a2804..5846d784c88ccc 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: