Java gcd gcd(int a, int b)

Here you can find the source of gcd(int a, int b)

Description

gcd

License

BSD License

Declaration

public static int gcd(int a, int b) 

Method Source Code

//package com.java2s;
/**/* ww w  . jav  a2 s  .  co  m*/
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author The JCodec project
 * 
 */

public class Main {
    public static int gcd(int a, int b) {
        if (b != 0)
            return gcd(b, a % b);
        else
            return a;
    }

    public static long gcd(long a, long b) {
        if (b != 0)
            return gcd(b, a % b);
        else
            return a;
    }
}

Related

  1. gcd(int a, int b)
  2. gcd(int a, int b)
  3. gcd(int a, int b)
  4. gcd(int a, int b)
  5. gcd(int a, int b)
  6. gcd(int a, int b)
  7. gcd(int a, int b)
  8. gcd(int a, int b)
  9. gcd(int a, int b, int... rest)