]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add more examples to the recipe docs (GH-106782)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Sat, 15 Jul 2023 19:43:09 +0000 (14:43 -0500)
committerGitHub <noreply@github.com>
Sat, 15 Jul 2023 19:43:09 +0000 (14:43 -0500)
Demonstrate that factor() works for large composites and large primes.

Doc/library/itertools.rst

index a2d1798a2c6da13ee3a0f429d0aacf5e38c9dbed..f88525456ff939c41768ec2cca1543473898a1cf 100644 (file)
@@ -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)