Advertisement
Guest User

Untitled

a guest
Nov 7th, 2019
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             function displayPrimes(current, max) {
  2.                 if (current > max)
  3.                     return;
  4.                    
  5.                 if (current >= 2) {
  6.                    
  7.                     var valid = true;
  8.                    
  9.                     for (var i = 2; i < current; i++) {
  10.                         if (current % i === 0)
  11.                             valid = false;
  12.                     }
  13.                    
  14.                     if (valid)
  15.                         console.log(current);
  16.                    
  17.                 }
  18.                
  19.                 current++;
  20.                 displayPrimes(current, max);
  21.             }
  22.            
  23.             displayPrimes(0, 20);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement