Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to find hcf of 2 numbers in javascript

var a = userInput[0].split(" ").map(Number)
while(a[0] != a[1])
{
    if(a[0] > a[1]) { 
        a[0] = a[0] - a[1];
    }
    else {
        a[1] =a[1] - a[0]; 
    }
}
console.log(a[0])
 
PREVIOUS NEXT
Tagged: #find #hcf #numbers #javascript
ADD COMMENT
Topic
Name
3+9 =