初学python 的一个语法错误
def isPrimer(d): tt = range(2,d^0.5) for i in tt if d%i == 0 : return False else: pass return Truecount = 1num = 3result while count <= 1000: if isPrimer(num) == True: count ++ result = num num += 2print ('the 1000 primer is ' ,result)
import mathdef isPrime(d): for i in xrange(3, int(math.sqrt(d)+1), 2): if d%i == 0 : return False return Truecount = 2num = 3 while count <= 1000: if isPrime(num): count += 1 result = num num += 2print 'the 1000th prime is ', result#the 1000th prime is 7919