1// take input from the user
2const lowerNumber = 1
3var higherNumber = 10000
4
5console.log(`The prime numbers between ${lowerNumber} and ${higherNumber} are:`);
6
7// looping from lowerNumber to higherNumber
8for (let i = lowerNumber; i <= higherNumber; i++) {
9 let flag = 0;
10
11 // looping through 2 to user input number
12 for (let j = 2; j < i; j++) {
13 if (i % j == 0) {
14 flag = 1;
15 break;
16 }
17 }
18
19 // if number greater than 1 and not divisible by other numbers
20 if (i > 1 && flag == 0) {
21 console.log(i);
22 }
23}