maths.prime_numbers

Attributes

number

Functions

benchmark()

Let's benchmark our functions side-by-side...

fast_primes(→ collections.abc.Generator[int, None, None])

Return a list of all primes numbers up to max.

primes(→ collections.abc.Generator[int, None, None])

Return a list of all primes numbers up to max.

slow_primes(→ collections.abc.Generator[int, None, None])

Return a list of all primes numbers up to max.

Module Contents

maths.prime_numbers.benchmark()

Let’s benchmark our functions side-by-side…

maths.prime_numbers.fast_primes(max_n: int) collections.abc.Generator[int, None, None]

Return a list of all primes numbers up to max. >>> list(fast_primes(0)) [] >>> list(fast_primes(-1)) [] >>> list(fast_primes(-10)) [] >>> list(fast_primes(25)) [2, 3, 5, 7, 11, 13, 17, 19, 23] >>> list(fast_primes(11)) [2, 3, 5, 7, 11] >>> list(fast_primes(33)) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] >>> list(fast_primes(1000))[-1] 997

maths.prime_numbers.primes(max_n: int) collections.abc.Generator[int, None, None]

Return a list of all primes numbers up to max. >>> list(primes(0)) [] >>> list(primes(-1)) [] >>> list(primes(-10)) [] >>> list(primes(25)) [2, 3, 5, 7, 11, 13, 17, 19, 23] >>> list(primes(11)) [2, 3, 5, 7, 11] >>> list(primes(33)) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] >>> list(primes(1000))[-1] 997

maths.prime_numbers.slow_primes(max_n: int) collections.abc.Generator[int, None, None]

Return a list of all primes numbers up to max. >>> list(slow_primes(0)) [] >>> list(slow_primes(-1)) [] >>> list(slow_primes(-10)) [] >>> list(slow_primes(25)) [2, 3, 5, 7, 11, 13, 17, 19, 23] >>> list(slow_primes(11)) [2, 3, 5, 7, 11] >>> list(slow_primes(33)) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] >>> list(slow_primes(1000))[-1] 997

maths.prime_numbers.number