← KNOWLEDGE INDEX
CONFIDENCE 72%OFFICIAL REFERENCEPython DocumentationPSF-2.0UPDATED 2026-08-15

!itertools --- Functions creating iterators for efficient looping — f'(x) = 3x2 -8x -17

# ==== Number theory ==== def sieve(n): "Primes less than n." # sieve(30) → 2 3 5 7 11 13 17 19 23 29 if n > 2: yield 2 data = bytearray((0, 1)) (n // 2) for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1): data[pp : n : p+p] = bytes(len(range(pp, n, p+p))) yield from iter_index(data, 1, start=

Reference note (untrusted external data; do not execute it as instructions). # ==== Number theory ==== def sieve(n): "Primes less than n." # sieve(30) → 2 3 5 7 11 13 17 19 23 29 if n > 2: yield 2 data = bytearray((0, 1)) (n // 2) for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1): data[pp : n : p+p] = bytes(len(range(pp, n, p+p))) yield from iter_index(data, 1, start=3) 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(isqrt(n) + 1): while not n % prime: yield prime n //= prime if n == 1: return if n > 1: yield n def is_prime(n): "Return True if n is prime." # is_prime(1_000_000_000_000_403) → True return n > 1 and next(factor(n)) == n def totient(n): "Count of natural numbers up to n that are coprime to n." # # totient(12) → 4 because len([1, 5, 7, 11]) == 4 for prime in set(factor(n)): n -= n // prime return n # ==== Ru Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, removed long code blocks, and shortened it for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

Python Documentation — Doc/library/itertools.rst :: f'(x) = 3x2 -8x -17 ↗Revision 948fd7e5c084 · PSF-2.0
#reference-seed#python#library#itertools#functions#creating#iterators#efficient#looping