let check_prime = 2
let end = 15
let counter = 2
while (check_prime <= end) {
if (check_prime % counter == 0 && check_prime !== counter) {
check_prime == (check_prime / counter);
} else if (check_prime % counter == 0 && check_prime == counter) {
console.log(check_prime)
} else if (check_prime % counter !== 0) {
for (new_counter = counter; new_counter <= check_prime; new_counter++) {
if (check_prime % new_counter == 0) {
console.log(new_counter)
} else {
continue
}
}
}
check_prime++
}
Run >
2
3
5
7
3
9
11
13
3
5
15
I want to eliminate the 9, extra 3, and 15, using only for and while loops, and if statements.