Skip to content

Commit

Permalink
Add more examples to the recipe docs (pythonGH-106782)
Browse files Browse the repository at this point in the history
Demonstrate that factor() works for large composites and large primes.
  • Loading branch information
rhettinger committed Jul 15, 2023
1 parent 22980dc commit e2ec0ba
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,8 @@ The following recipes have a more mathematical flavor:
def factor(n):
"Prime factors of n."
# factor(99) --> 3 3 11
# 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:
quotient, remainder = divmod(n, prime)
Expand Down

0 comments on commit e2ec0ba

Please sign in to comment.