js和python获取1-100之间的质数
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)
博客园作者:herry菌朋友,看到这里,关注作者的公众号吧,不漏掉更新哦
![]()