showing results for - "js print all prime numbers"
Braylee
22 May 2019
1// program to print prime numbers between the two numbers
2
3// take input from the user
4const lowerNumber = parseInt(prompt('Enter lower number: '));
5const higherNumber = parseInt(prompt('Enter higher number: '));
6
7console.log(`The prime numbers between ${lowerNumber} and ${higherNumber} are:`);
8
9// looping from lowerNumber to higherNumber
10for (let i = lowerNumber; i <= higherNumber; i++) {
11    let flag = 0;
12
13    // looping through 2 to user input number
14    for (let j = 2; j < i; j++) {
15        if (i % j == 0) {
16            flag = 1;
17            break;
18        }
19    }
20
21    // if number greater than 1 and not divisible by other numbers
22    if (i > 1 && flag == 0) {
23        console.log(i);
24    }
25}
queries leading to this page
prime number print in javascripttprint prime number jsprint prime numbers jsprint all prime numbers till n in javascriptjavascript calculate prime numbersadd all prime numbers javascriptjavascript program to print prime numbersprint prime numbers till given value using javascripthow to get prime numbers in javascriptjavascript function to print out n prime numbersprint n prime numbers in javascriptprint prime number upto a given value javascriptjavascript function to print prime numberswrite a program to print prime numbers from 1 to 100 in javascriptjavascript program to find prime numbers how to print all prime numbers up to a given number in javascripthow to find prime numbers javascriptfunction for prime numbers in jshow to print all prime number between given numbers in jsprint prime numbers till given value using java javascriptjavascript to generate all prime numberlist prime numbers javascriptprint prime number javascriptprint prime numbers using javascripthow to find prime numbers in javascriptprint prime number using user value in jsjavascript program to print all prime numbers in an arrayprint all 3 digit prime numbers jsprint number of prime number user value in java javascriptfunction to print out prime numbers javascriptget prime numbers javascriptprime number print in javasciptprogram to find the prime numbers upto n in javascriptjavascript calculate all prime numbersjavascript to find prime numbersfind all prime numbers till given number javascriptjs find all prime numbersalgorithm for prime numbers in javascriptjs get all prime numbers before a numberwrite a javascript program to find prime numberjs program to find prime numbersjs print all prime numbers