GCD/HCF calculator is used to find the greatest common divisor or the largest positive integer that divides the numbers without a remainder of given numbers.
Features
a) Used to find the greatest common divisor of two or more numbers.
c) Handy tool to determine the highest common factor of given numbers.
d) The calculator works fine for positive integers.
Preview
HIGHEST COMMON FACTOR
Code
Javascript Code
<!-- Script by hscripts.com -->
<!-- Copyright of HIOXINDIA -->
<!-- More scripts @www.hscripts.com -->
<script type="text/javascript">
function calculate()
{
var tot=document.getElementById("tot").value;
var count=2;
if(tot>1){
var n1=document.getElementById("txt0").value;
var n2=document.getElementById("txt1").value;
var res1=n1*n2;
n1=calc(n1,n2);
while(count<tot){
var gg="txt"+count;
n2=document.getElementById(gg).value;
res1=n1*n2;
n1=calc(n1,n2);
count=count+1;
}
}
document.getElementById("re").style.display="block";
document.getElementById("resul").value=n1;
}
function calc(n1,n2)
{
var num1,num2;
if(n1 < n2){
num1=n1;
num2=n2;
}
else{
num1=n2;
num2=n1;
}
var remain=num2%num1;
while(remain>0){
num2=num1;
num1=remain;
remain=num2%num1;
}
return num1;
}
function newtextbox(val)
{
if(val<6){
var dd=document.getElementById('new1');
var en=document.getElementById('va').style.display='block';
if(dd.innerHTML==""){
for(var i=0;i<val;i++)
{
var textbox=document.createElement('input');
textbox.setAttribute("type","text");
var textname="txt"+i;
textbox.setAttribute("id",textname);
textbox.setAttribute("size","4");
dd.appendChild(textbox);
}
}
else{
for(var i=0;i<val;i++)
{
var gg="txt"+i;
dd.removeChild(document.getElementById(gg));
document.location.reload();
}
}
}
else{
alert("Enter values upto 5 only");
}
}
</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) Here,the function "calculate()" is used to find the gcd/gcf of given numbers.
c) Entering the numbers and a button click completes the calculation of highest common factor.
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.