I am attempting to write a code to calculate the 1000th prime number and I'm running into an issue with my loop counter that i don't understand.
prime_test = 1
count=0
for count in range(0,1001):
for divisor in range(2,prime_test):
if (prime_test % divisor) == 0:
break
else:
print(prime_test)
count += 1
prime_test+=1
Could someone please explain why the above code is dysfunctional? The problem is that the count variable iterates at the same rate as the prime_test variable. How do I separate the two such that count only increases when a new prime is found and not when the loop is engaged?