prime number program in java - CodeTextPro | Web Tutorial | Technology

CodeTextPro.com Provides - Web design, Technology gyan, Digital marketing, Online earnings, Seo, Adsense, Technology news, Motivation and inspiration, Latest Technology Affairs, Gadgets, Blogging

Wednesday, January 9, 2019

prime number program in java

Prime Number
<html>
<head>
<title> my web page..</title>
<style type="text/css">

#d1
{
top:80px;
left:400px;
width:20%;
height:40%;
background-color:aquamarine;
border: 2px black solid;
color:brown;
padding-left:215px;
}

</style>

<script type="text/javascript">

function prime()

{
var n1=parseInt(document.getElementById("t1").value);


var n2=parseInt(document.getElementById("t2").value);



for(var i=n1;i<=n2;i++)

   {
       
var flag=0;

   for(var j=2;j<i;j++)
       {
           if(i%j==0)
            {
                 flag=1;
break;
            }
}
       if(flag==0) 
      {       
         document.getElementById("d1").innerHTML+=i+"<br>";
      }
}
}
</script>
<body>
<table>
<tr>
<td> 
From : <input type="text" size="15" id="t1"/> 
To : <input type="text" size="15" id="t2"/> <input type="button" value="ok" onclick="prime()"/>
</td></tr>
</table>
<div id="d1">
</div>
</body>
</html>


Output:
case1:




case2:




No comments:

Post a Comment