I have made a program to find primes, but when I try to get the 10001st prime it isn't correct. I can't figure out why.
I haven't really tried much because I have no idea what to try.
import math
startingPrimes = [2,3, 5, 7, 11, 13, 17, 19]
for times in range (2):
primeList = []
numbersToBeTested = 0
for _ in range (startingPrimes[len(startingPrimes)-1]**2):
primeList.append(_ + 2)
print ()
numbersToBeTested = startingPrimes[len(startingPrimes)-1]**2
print (numbersToBeTested)
divisor = 0
term = 0
dividend = 0
position = 0
while divisor < math.sqrt(len(primeList)):
term = 0
divisor = startingPrimes[position]
dividend = primeList[position]
while term + 1 < len(primeList):
term = term + 1
if primeList[term] % divisor == 0:
if primeList[term] != divisor:
primeList.remove(primeList[term])
position = position + 1
startingPrimes = primeList
for termOfList in range (len(primeList)):
print (primeList[termOfList])
print ("How many primes: " + str(len(primeList)))
print ("10001st prime: " + str(primeList[10000]))
It gives me 90373 which is wrong! Please help!