programming-examples/js/Conditional/Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers..js
2019-11-15 12:59:38 +01:00

16 lines
242 B
JavaScript

var a = 2154; //First number
var b = 458; //Second number
var gcd;
while (a!=b)
{
if (a>b)
{
a = a -b;
}
else
{
b = b - a;
}
}
gcd = a;
console.log(gcd);