js
for (let i = 2; i <= 100; i++) { let iszs = true for (let j = 2; j < i; j++) { if (i % j === 0) { iszs = false break } } if (iszs) { zs.push(i) } } console.log(zs)
python
zs = [] for i in range(2, 101): iszs = True for j in range(2, i): if(i % j == 0): iszs = False break if(iszs): zs.append(i) print(zs)
标签:python,质数,js,iszs,range,zs From: https://www.cnblogs.com/wuhairui/p/17864978.html