No.1 f=lambda n: [x for x in range(1,n) if not [y for y in range(2,x) if x%y ==0 ]] No.2 def prime(n): for i in range(1,n+1): for j in range(2,int(i**0.5+1)): if i % j == 0: break else: yield i NO.3(还没有搞懂.最高效的一种) def rwh_primes2(n = 10**6): ""&q…
#求10万以内所有素数 num = int(input(">>>")) strs = '' for i in range(2,num): for c in range(2,int(i**0.5)+1): if i%c == 0: break else: strs += str(i)+' ' print(strs) 方法2: print(2) for i in range(3,100001,2): if i>10 and i%10 == 5: continue e…