maths.prime_numbers =================== .. py:module:: maths.prime_numbers Attributes ---------- .. autoapisummary:: maths.prime_numbers.number Functions --------- .. autoapisummary:: maths.prime_numbers.benchmark maths.prime_numbers.fast_primes maths.prime_numbers.primes maths.prime_numbers.slow_primes Module Contents --------------- .. py:function:: benchmark() Let's benchmark our functions side-by-side... .. py:function:: fast_primes(max_n: int) -> collections.abc.Generator[int] 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 .. py:function:: primes(max_n: int) -> collections.abc.Generator[int] 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 .. py:function:: slow_primes(max_n: int) -> collections.abc.Generator[int] 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 .. py:data:: number