programming-examples/js/Conditional/Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers..js

16 lines
242 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
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);