added js version of euclid's algorithm