827
In this example we display all the prime numbers between 1 and 100.
A prime number is a positive integer that is only divisible by 1 and itself
Example
// program to print prime numbers between 1 and 100 console.log(`The prime numbers are:`); // looping from 1 to 100 for (let i = 1; i <= 100; i++) { let flag = 0; // looping through 2 to number for (let j = 2; j < i; j++) { if (i % j == 0) { flag = 1; break; } } // if number greater than 1 and not divisible by other numbers if (i > 1 && flag == 0) { console.log(i); } }
This will display the following
The prime numbers are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97