Here is my prime number finding algorithm -- it works great (and very fast) up until the limit is set above 173, then it starts throwing
ValueError: list.remove(x): x not in list
I don't understand why this is when it works absolutely fine up until the limit is 174 or above -- here is my code.
def primefinder(limit):
primes = [2, 3]
for i in range(1, (limit / 6 + 1)):
primes.append(6 * i - 1)
primes.append(6 * i + 1)
for i in primes[:]:
if i > 24:
for x in primes:
if x <= i ** 0.5:
if i % x == 0:
primes.remove(i)
continue
else:
break
if limit % 6 == 0:
primes.remove(primes[-1])
return primes