On Thu, Jul 12, 2018, 7:56 AM Serhiy Storchaka <storch...@gmail.com> wrote:

> * isprime(n)
> Tests if n is a prime number.
>

How would you test this? The Miller-Rabin Primality test? For large
numbers, iterating through candidate prime divisors is pricey.

* primes()
> Returns an iterator of prime numbers: 2, 3, 5, 7, 11, 13,...
>

How would you implements this? Sieve of Eratosthenes is really fun to show
students as a Python generator function. But the cached primes DO grow
unboundedly as you utilize the generator. Wheel factorization as first
pass? Do you cached the first N primes so the each instance of iterator can
provide initial elements much faster? What is N?

>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to