Java gcd gcd1(long given1, long given2)

Here you can find the source of gcd1(long given1, long given2)

Description

gcd

License

Open Source License

Declaration

public static long gcd1(long given1, long given2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static long gcd1(long given1, long given2) {
        if (given1 == 0 || given2 == 0)
            return -1;
        long a = given1 % given2;
        long b = given2 % a;
        long t = 0;
        while (b != 0) {
            t = b;//from w  w  w.j a  v a2  s .c o  m
            b = a % b;
            a = t;
        }
        return a;
    }
}

Related

  1. gcd(long u, long v)
  2. gcd(long x, long y)
  3. gcd(long x, long y)
  4. gcd(long[] array)
  5. gcd(long[] array)
  6. GCDHelper(long a, long b)
  7. gcdMultiple(int[] nums)
  8. gcdPositive(int a, int b)
  9. gcdPositive(int... args)