Extended Euclidean algorithm

    Returns r, s, t such that r = s*a + t*b and r is gcd(a, b)

    See <https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm>
165472
def extended_euclidean_algorithm(a, b):
    
    r0, r1 = a, b
    s0, s1 = 1, 0
    t0, t1 = 0, 1
    while r1 != 0:
        q = r0 // r1
        r0, r1 = r1, r0 - q*r1
        s0, s1 = s1, s0 - q*s1
        t0, t1 = t1, t0 - q*t1
    return r0, s0, t0
1614
private static int computeE3(int a, int b, int d, int e, int g, int h)
    {
        if (d == b && e != g || d == h && e != a)
        {
            return d;
        }
        return e;
    }
396630
function ( vectorA, vectorB, vectorC ) {

		var s, a, b, c,
			tmp = THREE.GeometryUtils.__v1;

		tmp.sub( vectorA, vectorB );
		a = tmp.length();

		tmp.sub( vectorA, vectorC );
		b = tmp.length();

		tmp.sub( vectorB, vectorC );
		c = tmp.length();

		s = 0.5 * ( a + b + c );

		return Math.sqrt( s * ( s - a ) * ( s - b ) * ( s - c ) );

	}
1294918
static public function lcm($a, $b)
    {
        $a = abs($a);
        $b = abs($b);

        if ($a === 0 || $b === 0) {
            return 0;
        }

        $a = $a / self::gcd($a, $b);

        return $a * $b;
    }
525394
public static int gcd(int[] numbers) {

    if (numbers.length == 1)
      return numbers[0];

    int g = gcd(numbers[0], numbers[1]);

    for (int i = 2; i < numbers.length; i++)
      g = gcd(g, numbers[i]);

    return g;
  }
859292
function lcm(a, b) {
		// The least common multiple is the absolute value of the product of
		// the numbers divided by the greatest common denominator
		return Math.abs(a * b) / gcd(a, b);
	}
111412
def extended_gcd(b,m,_recursion_depth=0)
      if b % m == 0
        temp = [0,1]
        return temp
      else
        temp = extended_gcd(m, b % m, _recursion_depth+1)
        temp2 = [temp[1], temp[0]-temp[1] * ((b/m).to_i)]
        if _recursion_depth == 0
          return temp2[0] % m
        else
          return temp2
        end
      end
    end
293877
public static double euclideanSq(TupleDesc_F64 a, TupleDesc_F64 b) {
		final int N = a.value.length;
		double total = 0;
		for( int i = 0; i < N; i++ ) {
			double d = a.value[i]-b.value[i];
			total += d*d;
		}

		return total;
	}
1127923
def _lcm(a, b):
    
    if a == 0 or b == 0:
        return 0
    else:
        return abs(a * b) // gcd(a, b)
503453
public static double euclidean(EuclideanCoordinate coord1, EuclideanCoordinate coord2) {
		int size = Math.min(coord1.dimensions(), coord2.dimensions());
		double distance = 0;
		for(int i = 0; i < size; i++) {
			double diff = coord1.get(i) - coord2.get(i);
			distance += diff * diff;
		}
		distance = Math.sqrt(distance);
		return distance;
	}
441526
def erank(self):
        
        r = self.r
        n = self.n
        d = self.d
        if d <= 1:
            er = 0e0
        else:
            sz = _np.dot(n * r[0:d], r[1:])
            if sz == 0:
                er = 0e0
            else:
                b = r[0] * n[0] + n[d - 1] * r[d]
                if d is 2:
                    er = sz * 1.0 / b
                else:
                    a = _np.sum(n[1:d - 1])
                    er = (_np.sqrt(b * b + 4 * a * sz) - b) / (2 * a)
        return er
1269112
public static function gcd($a, $b)
    {
        $ta = abs($a);
        $tb = abs($b);
        while ($tb != 0) {
            $tmp = $tb;
            $tb = $ta % $tb;
            $ta = $tmp;
        }
        
        return $ta;
    }
799496
function r(a, b) {
        var c = b - a;
        var arr = new Array(c);
        while (c--)
            arr[c] = --b;
        return arr;
    }
1250089
function gcd(a, b) {
    var t;
    while (b) {
      t = a;
      a = b;
      b = t % b;
    }
    return Math.abs(a);
  }
778678
function() {

      var t;
      var a = this['n'];
      var b = this['d'];
      var res = [];

      if (isNaN(this['n']) || isNaN(this['d'])) {
        return res;
      }

      do {
        res.push(Math.floor(a / b));
        t = a % b;
        a = b;
        b = t;
      } while (a !== 1);

      return res;
    }
492920
def _gcd_array(X):
    
    greatest_common_divisor = 0.0
    for x in X:
        greatest_common_divisor = _gcd(greatest_common_divisor, x)

    return greatest_common_divisor
102484
def euclidean_dissim(a, b, **_):
    """"""
    if np.isnan(a).any() or np.isnan(b).any():
        raise ValueError("Missing values detected in numerical columns.")
    return np.sum((a - b) ** 2, axis=1)