求a~b的范围内的素数:
1,p=[p for p in range(a,b) if 0 not in [p%d for d in range(2,int(math.sqrt(p)))]]
2,def is_prime(p):
return 0 not in [p%d for d in [2,int(math.sqrt(p))]]
3,is_prime = (lambda x:0 not in [x%d for d in [2,int(math.sqrt(x))]])
求a~b的范围内的素数:
1,p=[p for p in range(a,b) if 0 not in [p%d for d in range(2,int(math.sqrt(p)))]]
2,def is_prime(p):
return 0 not in [p%d for d in [2,int(math.sqrt(p))]]
3,is_prime = (lambda x:0 not in [x%d for d in [2,int(math.sqrt(x))]])