📜  python中带有列表理解的素数列表 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:01.490000             🧑  作者: Mango

代码示例1
n = 20

primes = [i for i in range(2, n + 1) if all(i%j != 0 for j in range(2, int(i ** 0.5) + 1))]

print(primes)