Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function displayPrimes(current, max) {
- if (current > max)
- return;
- if (current >= 2) {
- var valid = true;
- for (var i = 2; i < current; i++) {
- if (current % i === 0)
- valid = false;
- }
- if (valid)
- console.log(current);
- }
- current++;
- displayPrimes(current, max);
- }
- displayPrimes(0, 20);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement