javascript - How to find all prime numbers within 200 without using functions
巴扎黑2017-05-19 10:29:40
0
3
889
How to find all prime numbers within 200 without using functions. Because I haven’t talked about functions in class yet, but there is this question in my homework
for (let i = 1; i <= 200; i++) {
let flag = 1;
while (flag) {
if (i % flag === 0 && flag !== 1 && flag !== i) {
flag = false;
}
if (flag === i) {
flag = false;
console.log(i)
}
flag = flag ? flag + 1 : false;
}
}
var sum=0;
printf("%d", 2);
printf("%d", 3);
printf("%d", 5);
...