DEV Community

Discussion on: Infinite list of prime numbers using Python generators

Collapse
 
billybobza profile image
Billy Einkamerer • Edited

Thanks for this - it was super helpful.
I hacked it a bit and added a value limit for the prime number check, so that you can check the prime numbers up to X.

Changed up the prime generator function to have a limit (also set a default limit):

then used that limit in the call of the generator into a list:

so no longer need itertools and islice.

Collapse
 
alebian profile image
Alejandro Bezdjian

Iā€™m glad that you find it useful šŸ™‚