# Check Prime Number

A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers.

Prime numbers are numbers that have only 2 factors: 1 and themselves.
Check the number is prime number or not , enter any number.

Output here
``````<html>
<title></title>
<body>
<input type="text" name="t1" id="t1">
<input type="button" value="Submit" onclick="check_prime()">
<div id=d1></div>
<script type="text/javascript">
function check_prime(){
x=document.getElementById("t1").value
x=parseInt(x)
if(Number.isInteger(x)){
str='';

flag=0
for(j=2;j<x;j++){
if(x%j == 0){
flag=1
break;
}

}
if(flag==0){
str= x + " Is a Prime Number ";
}else{
str= x + " Is not a Prime Number ( Composite Number ) ";
}
document.getElementById('d1').innerHTML= str
}else{
document.getElementById('d1').innerHTML="Enter an Integer  "
}
}
</script>
</body>
</html>``````
 isInteger() Checking if input number is integer or not parseInt() function to convert string to number

Subscribe to our YouTube Channel here

## Subscribe

* indicates required
Subscribe to plus2net

plus2net.com