So I'm trying to find the 10,001st prime #. Here's my code -
counter = 3
primes = [1]
while len(primes) < 10002:
for i in range(2, counter):
if counter % i == 0:
counter += 1
else:
primes.append(counter)
counter += 1
print counter
So what I get as an output in primes is a list of numbers, the first few numbers are 1, 3, 5, 7, 11... so far, so good... 13, 17, 19, 23, 27... wait, 27? So at that point it breaks down and starts returning mostly primes but not all primes. And it takes forever.
I'm new to programming, made it through CodeAcademy's Python course and now trying to figure out how to get past what was essentially just an introduction to the grammar. I don't come from a math background, so while I know what a prime is, I know there are far better ways to go about this. If there's anyone in a similar boat who wants to "partner up" and work together on learning Py2.7, I'm more than happy to.