Ad
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • function prime_checker (n) {
      if ([0,1].includes(n)) return false;
      for(let i = 2; i < n; i++) {
        if(n % i === 0) return false;
      }
      return true;  
    }
    • function prime_checker (n) {
    • if (n === 1 || n === 0) return false;
    • if ([0,1].includes(n)) return false;
    • for(let i = 2; i < n; i++) {
    • if(n % i === 0) return false;
    • }
    • return true;