Advertisement
EntropyStarRover

Prime numbers

Mar 3rd, 2019
178
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function prime(input){
  2.  
  3.     let upper=Number(input.shift());
  4.  
  5.     for (var counter = 2; counter <= upper; counter++)  {
  6.         let isPrime = true;
  7.      
  8.         for (var div = 2; div <counter; div++) {
  9.        
  10.             if (counter % div === 0) {
  11.                 isPrime=false;}
  12.         }
  13.    
  14.         if (isPrime==true) {
  15.         console.log(counter);}
  16.     }
  17. }
Advertisement
RAW Paste Data Copied
Advertisement