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}