Skip to content

Commit

Permalink
Sync factor with CPython GH-106817
Browse files Browse the repository at this point in the history
  • Loading branch information
bbayles committed Jul 17, 2023
1 parent f55a41d commit 9c6f616
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions more_itertools/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,14 +927,13 @@ def factor(n):
"""
for prime in sieve(math.isqrt(n) + 1):
while True:
quotient, remainder = divmod(n, prime)
if remainder:
if n % prime:
break
yield prime
n = quotient
n //= prime
if n == 1:
return
if n >= 2:
if n > 1:
yield n


Expand Down

0 comments on commit 9c6f616

Please sign in to comment.