【逃兵】【python】找质数
def get_primes(n: int) -> list:"""
return a list containing all prime numbers less than n.
"""
if n <= 2:
return []
isprime =
result =
for i in range(3, n, 2):
if isprime:
result.append(i)
for j in range(0, len(result)):
if i * result >= n:
break
isprime] = False
if i % result == 0:
break
return result
n=int(input())
print(*get_primes(n),sep='\n')
页:
[1]