From: Raymond Hettinger Date: Sat, 15 Jul 2023 19:43:09 +0000 (-0500) Subject: Add more examples to the recipe docs (GH-106782) X-Git-Tag: v3.13.0a1~1381 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2ec0bad67552e27174255db86dda90fc72e6694;p=thirdparty%2FPython%2Fcpython.git Add more examples to the recipe docs (GH-106782) Demonstrate that factor() works for large composites and large primes. --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index a2d1798a2c6d..f88525456ff9 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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)