mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
Minor code clean-up for the factor() recipe (GH-108114)
This commit is contained in:
parent
9bb576cb07
commit
6db39b1460
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user