summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2023-07-15 19:43:09 (GMT)
committerGitHub <noreply@github.com>2023-07-15 19:43:09 (GMT)
commite2ec0bad67552e27174255db86dda90fc72e6694 (patch)
tree85fa3ab6ff34ebecaf428f91a6804753912872c4
parent22980dc7c9dcec4b74fea815542601ef582c230e (diff)
downloadcpython-e2ec0bad67552e27174255db86dda90fc72e6694.zip
cpython-e2ec0bad67552e27174255db86dda90fc72e6694.tar.gz
cpython-e2ec0bad67552e27174255db86dda90fc72e6694.tar.bz2
Add more examples to the recipe docs (GH-106782)
Demonstrate that factor() works for large composites and large primes.
-rw-r--r--Doc/library/itertools.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index a2d1798..f885254 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)