mirror of
https://github.com/python/cpython.git
synced 2025-08-11 04:19:06 +00:00
[3.12] Sync factor() recipe with main branch (gh-110231)
This commit is contained in:
parent
25bf0564c4
commit
221c8d64e6
1 changed files with 1 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue