thanks, these two improvements actually make a lot of difference in performance.
improved code:
new code: 0.273015499114023s to calculate
improved code:
def calcPrim(number): primList = [] primList.append(2) value = 3 while len(primList) < number: if checkPrim(primList, value): primList.append(value) value += 2 primList.insert(0, 1) return primList def checkPrim(primList, value): for prim in primList: if prim>sqrt(primList[-1]+2): break if value%prim == 0: return False return True number = 10001 primList = calcPrim(number) print('{}th prime = {}'.format(number,primList[number-1]))old code: 5.741328477859497s to calculate
new code: 0.273015499114023s to calculate