# GCD/LCM of 2 numbers

Below is the algorithm:-

console.log("GCD of 35 and 75 ", gcd(35, 75)); console.log("LCM of 35 and 75 ", (35*75)/gcd(35,75)); /* function to calculate GCD/HCF of 2 numbers */ function gcd(i, j) { var r = -1; if (i < j) { var temp; temp = i; i = j; j = temp; } while (r) { r = i - parseInt(i / j) * j; i = j; j = r; } return i; }

goli202084 Changed status to publish