HCF

PHOTO EMBED

Sat Dec 04 2021 00:37:31 GMT+0000 (Coordinated Universal Time)

Saved by @tolanisirius

function gcd(a,b){
   let hcf;
   for (let i = 1; i <= a && i <= b; i++) {

    // check if is factor of both integers
    if( a % i == 0 && b % i == 0) {
        hcf = i;
    }
}
  return hcf;
}
 gcd(6, 15);
content_copyCOPY

https://www.jshero.net/en/koans/ggt.html