I want to get a prime number list. 15 should not occur as per the definition of prime number. But it showed on my output. I don't know what happened.
python
import math
n = input('n')
n = int(n)
A = list(range(2,n+1))
print(A)
n_=math.floor(math.sqrt(n))
m = list(range(2,n_+1))
for i in range(0,len(m)):
if m[i]!=0:
j = m[i]^2
while j<= n:
A[j-2] = 0
j = j+m[i]
A[0]=2;
print(A)
print(m)
I expect the output to be [2, 3, 0, 5, 0, 0, 0, 9, 0, 11, 0, 0, 0, 0, 0, 17, 0, 0, 0]
Actual output is [2, 3, 0, 5, 0, 0, 0, 9, 0, 11, 0, 0, 0, 15, 0, 17, 0, 0, 0]