DEV Community

Discussion on: Infinite list of prime numbers using Python generators

Collapse
 
frankzielen profile image
Frank

Nice post but 2 is not prime. You need to shift the n==2 if-statement to the top.

Collapse
 
alebian profile image
Alejandro Bezdjian

Hi Frank, I’m afraid 2 is a prime number

Collapse
 
frankzielen profile image
Frank

Hi Alejandro, yes, 2 is prime but your code says no.

Thread Thread
 
b_wil34 profile image
Bwillis

The code returns True if it is a prime number. It says if n == 2, return True, which states that 2 is a prime number, because it is actually a prime number