function findPrime(to) { let factor; for (let n = 0; n < to; n++) { factor = 0 for (let p = 0; p < to; p++) if (n % p == 0) factor++; if (factor == 2) console.log(n); } } console.log(30) //2 3 5 7 11 13 17 19 23 29