So I'm trying to write a short programme that will find prime numbers, and discard non-prime numbers. This was my attempt at writing it:
def prime(x):
while True:
for y in range(2,x):
if x%y == 0 :
x = x + 1
else:
print( str(x) + " is a prime number")
x = x + 1
return x
prime(x)
try:
x = 3
while True:
x = prime(x)
except:
print("NO MORe")
Instead of giving prime numbers this programme just gives all odd numbers, and im fairly sure its to do with the line:
for y in range(2,x):
But I'm not sure how to fix it, any pointers?