how to find hcf(gcd) in javascript