k=int(input())
res=[2]
for i in range(2,k+1):
if i%2==0:
continue
else:
for j in range(2,i):
if i%j==0 or j%2==0 :
break
else:
res.append(i)
print(res)
This code is for finding prime numbers in a given range of numbers. I tried to run the code but the list is having only number 2.Can anyone tell me what is happening. I i remove j%2==0.Its working.I just want to know my mistake
Aucun commentaire:
Enregistrer un commentaire