Java gcd gcd(long x, long y)

Here you can find the source of gcd(long x, long y)

Description

Implemented recursively with Euclidian Algorithm

License

Open Source License

Parameter

Parameter Description
x First number
y Second number

Return

GCD of x and y

Declaration

public static long gcd(long x, long y) 

Method Source Code

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

public class Main {
    /**// w  w  w  .j  a v a 2 s . c  o  m
     * Implemented recursively with Euclidian Algorithm
     * 
     * @param x
     *          First number
     * @param y
     *          Second number
     * @return GCD of x and y
     */
    public static long gcd(long x, long y) {
        return (y == 0) ? x : gcd(y, x % y);
    }
}

Related

  1. gcd(long a, long b)
  2. gcd(long a, long b)
  3. GCD(long a, long b)
  4. gcd(long a, long b)
  5. gcd(long u, long v)
  6. gcd(long x, long y)
  7. gcd(long[] array)
  8. gcd(long[] array)
  9. gcd1(long given1, long given2)