mirror of
https://github.com/python/cpython.git
synced 2025-08-15 14:20:55 +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_007) --> 47 59 360620266859
|
||||||
# factor(1_000_000_000_000_403) --> 1000000000000403
|
# factor(1_000_000_000_000_403) --> 1000000000000403
|
||||||
for prime in sieve(math.isqrt(n) + 1):
|
for prime in sieve(math.isqrt(n) + 1):
|
||||||
while True:
|
while not n % prime:
|
||||||
if n % prime:
|
|
||||||
break
|
|
||||||
yield prime
|
yield prime
|
||||||
n //= prime
|
n //= prime
|
||||||
if n == 1:
|
if n == 1:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue