####What's the greatest common divisor of two numbers?
'use strict';
let euclid = (int1, int2) {
if(int1 === int2)
return int1;
if(int1 > int2)
return euclid((int1-int2), int2);
else
return euclid(int1, (int2 - int1));
}
This is the OG version. It runs slow when there's a large difference between int1
and int2
.