I recently started learning java-script. I created a program which checks whether a number is a prime number or not. But I wanted to get all prime numbers from 1 to 100 at once without checking individually for each number. please show me how to get it done.(edit) I want them to be on the html page and not in the console
<!DOCTYPE html>
<html>
<head>
<title>
Check For Prime
</title>
<link rel="stylesheet" href="prime.css">
<script rel="text/javascript" src="prime.js"></script>
</head>
<body>
<div class="main">
<h1>Check for Prime</h1>
Enter Number : <input id="num"><br><br>
Number is : <input id="ans"><br><br>
<button id="bt1" onclick="check()">Check</button><br><br>
<button id="bt2" onclick="clr()">clear</button>
</div>
</body>
</html>
function check(){
var n = Number(document.getElementById("num").value);
var c = 0;
//for numbers 1 and 2
if(n == 1){
document.getElementById("ans").value = "Not Prime";
}
if(n == 2){
document.getElementById("ans").value = "Prime";
}
//for numbers other than 2
//increments c every time (x % n) is 0
for(x = 1 ; x <= n; x++){
if((n % x) == 0){
c = c + 1;
}
}
//for prime numbers c should be equal to two
//prime numbers have only two positive factors
if(c == 2){
document.getElementById("ans").value = " Prime ";
}
else{
document.getElementById("ans").value = "Not Prime";
}
}
//clear function
//clear input
function clr(){
document.getElementById("num").value = "";
document.getElementById("ans").value = " ";
}