Write a JavaScript program to find prime number.
CODING:
<html>
<body>
<h1><b>PRIME NUMBER IS=
<script type="text/javascript">
var i,j,k,n;
n=prompt("Input The Number of Prime 1 to:")
for(i=1;i<=n;i++)
{
k=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
k=1;
break;
}
}
if(k==0)
{
document.write(i + " ") }
}
</script>
</body>
</html>
CODING:
<html>
<body>
<h1><b>PRIME NUMBER IS=
<script type="text/javascript">
var i,j,k,n;
n=prompt("Input The Number of Prime 1 to:")
for(i=1;i<=n;i++)
{
k=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
k=1;
break;
}
}
if(k==0)
{
document.write(i + " ") }
}
</script>
</body>
</html>
Comments
Post a Comment