0

i have struggled a bit with this one. I need to reduce the time that this programm needs to find all the primes in a certain range. This is what I came up with thus far.

def generatePrimeList(lo=2, up=800):
print "generatePrimeList", lo, up
primeList = []
for x in range (lo, up):
    Prime = True
    for y in range(lo, int(math.sqrt(x))):
        if x % y == 0:
            Prime = False
            break
    if Prime:
        primeList.append (x)
return primeList
redouan
  • 5
  • 1

0 Answers0