HCF JS-code
Write a javascript program to find HCF.
<html> <head> <title> HCF</title> <script> function HCF() { var a,b,c,s,l; a=Number(document.getElementById("first").value); b=Number(document.getElementById("second").value); if(a>b) { l=a;s=b; } else { s=a;l=b; } c=s; for( ;l%s!=0;) { c= l%s; l=s; s=c; } document.getElementById("answer").value=c; // document.write("RESULT " +c); } </script> </head> <body bgcolor="grey"> <font size="5"> Enter the first number   <input id="first" type="text" placeholder="Smaller number" style ="padding: 10px 20px; border: 1px solid ;color: green">
<br><br> Enter the second number   <input id="second" type="text" placeholder="Larger number" style ="padding: 10px 20px; border: 1px solid ;color: green">
<br><br> <button onclick="HCF()" style="background-color:red; font-size: 25" >Click here to find HCF</button> <br><br> HCF of given integer   <input id="answer" type="text" placeholder="HCF" style ="padding: 10px 20px; border: 1px solid ;color: green"><br> </font> </body> </html>
Comments
Post a Comment