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

This commit is contained in:
Raymond Hettinger 2023-08-18 12:13:58 -05:00 committed by GitHub
parent 9bb576cb07
commit 6db39b1460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: