Javascript Prime Number calculator is used to find whether the given value is prime or not.
Enter the value into textbox and find whether the given value is prime or not.
Features
a) You can verify whether the given value is integer or not.
b) Check given value is prime or not.
c) This is free javascript calculator.
d) Copy the code from given textarea and use this calculator.
Preview
Enter value into Textbox to check whether it is prime or not.
Code
Javascript Code
<!-- Script by hscripts.com -->
<!-- Copyright of HIOXINDIA -->
<!-- More scripts @www.hscripts.com -->
<script type="text/javascript">
function pricalc()
{
var a=frm.txt.value;
if(a=="")
alert("Enter the value");
else
{
var num=parseInt(a);
var i;
for(i=2;i<num;i++)
{
var n;
n=num%i;
if(n==0)
{
alert("Not a Prime Number");
break;
}
}
if(i==num)
{
alert("Prime Number");
}
}
}
function isInteger(s)
{
var i;
s=s.toString(s);
for(i=0;i<s.length;i++)
{
var c=s.charAt(i);
if(isNaN(c))
{
alert("Given value is not a number");
frm.txt.value="";
return false;
}
}
return true;
}
</script>
<!-- Script by hscripts.com -->
For customization of this script or any script development, contact us at support@hscripts.com
Usage
a) Copy the javascript code into the head part of your HTML page.
b) Create a HTML form using the above HTML code.
c) Here,the function "pricalc()" is called to check whether the given value is prime or not. The function "isInteger()" is used to check the entered value is integer or not.
d) Copy the code into your page and use this calculator.
License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.