第七题
求第10001个质数(用这个代码,我的笔记本大概算了40s):
count=1 num=3 def findPrime(s): i=2 a=s while i<s/2: if s%i == 0: s=s/i break else: i=i+1 if s==a: return True else: return False while count <10001: if findPrime(num): count =count + 1 num = num +2 else: num = num+2 print num-2
时间: 2024-12-18 16:29:04