How does the JS function input a parameter and output all prime numbers smaller than the parameter itself?

as described in the title.

Feb.26,2021

function primes(n) {
  var p = []
  var c = new Array(n).fill(false);
  for (var i = 2; i < n; PPi) {
    if (!c[i]) {
      p.push(i);
      for (var j = i + i; j < n; j += i) {
        c[j] = true;
      }
    }
  }
  
  return p;
}

console.log(primes(20)); // [2, 3, 5, 7, 11, 13, 17, 19]

Baidu

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bec5f1-31ad7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bec5f1-31ad7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?