HCF Program in JS with flowchart and form values entered by the user.
Flowchart of the HCF programĀ

Javascript program to show the HCF.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <!DOCTYPE html> <html> <body> <h1>Java Script</h1> <h2>H C F in JAVASCRIPT<h2> <p>Given the first value is 4</p> <p>Given the second value is 6</p> <script> function gcd() { var m,n; m=4; n=6; while(m!=n){ if(m>n) {m=m-n; document.write("\nH.C.F of 4 & 6 is "+m); } else { n=n-m; } } } </script> <input type="button" value="show Result" OnClick="gcd()"/> </body> </html> |
javascript program to show the HCF with the form values entered by the user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <!DOCTYPE html> <html> <body> <h1>Java Script</h1> <h2>H C F in JAVASCRIPT<h2> <script> function gcd(a,b) { var m,n; m=a; n=b; while(m!=n){ if(m>n) m=m-n; else n=n-m; } document.write("\nH.C.F of "+a+" & "+b+" is "+m); } </script> Enter a value:<input type="text" name="enter" class="enter" value="" id="first"/></br></br> Enter a value:<input type="text" name="enter" class="enter" value="" id="second"/></br> <input type="button" value="show Result" OnClick="gcd(document.getElementById('first').value,document.getElementById('second').value)"/> </body> </html> |
Topic Covered
HCF Program in JS with flowchart and form values entered by the user.Ā
List of All Programs of Javascript :Ā Click Here .